| Posted: 13 January 2005 at 8:13pm | IP Logged
|
|
|
I've seen this rule posted here, which redirects requests for directories that do not end with a slash.
RewriteCond Host: (.*) RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]
I don't understand how the RewriteRule pattern works. Yaroslav, Lexey, or anybody else would you please walk me through it?
([^.?]+[^.?/])
My attempt at interpretation:
[^.?] means "Anything except (any single character (zero or one time only))."
Sorry not making sense. I understand you can match either a single character one time or a single character zero times. But what matches anything except that (signified by the caret)?
+ means "The preceding expression repeated one or more times." [^.?/] means "Followed by anything except (any single character (zero or one time only) or a slash)."
Also I was glad to see the pattern doesn't match requests ending in file names, so for example you don't get redirected to /index.html/ when you request /index.html. However I would like to understand how this works.
Thanks, Kevin
|