Forum Moderators: phranque
I was trying to create a RewriteRule to prevent redirection from a directory, because the directory were password protected. I created a rule like this:
RewriteCond %{REQUEST_URI} ^/mydirectory
RewriteRule (.*) - [L]
#... rest for redirect rules
So I suppose if I request
http:// mydomain.com / mydirectory
The HTTP variable REQUEST_URI should be set to
/mydirectory
However it does not seem to work. I looked at my HTTP header from my firefox plugin, the header has the content similar to this:
GET mydirectory/ HTTP/1.1
So i change my rule to:
RewriteCond %{THE_REQUEST} ^(GET¦POST)\s/worship [NC]
RewriteRule (.*) - [L]
And now this works just fine.
But I still don't understand what was wrong in the first syntax. Isn't the REQUEST_URI always set to the path after GET or POST int THE_REQUEST variable?
Thanks in advance,
Jason
RewriteRule ^mydirectory - [L] Basically, THE_REQUEST is the entire request line received from the client (e.g. browser or search engine robot), and is unaffected by internal rewrites or anything else; It is what the client sent to start this HTTP transaction.
So you might want to look at all the code in your .htaccess files, and make sure that no other rules might have been applied to requests for /mydirectory URL-paths, changing them before the first rule you posted gets evaluated.
Jim
I thought the URL was changed for the PATTERN matching in RewriteRule, and i did not realized that it could be change in %{REQUEST_URI} for RewriteCond.
If I were able to see the rewrite log, I can solve this puzzle. But again I am not allowed because of shared hosting.
Anyway thanks again. I learn something today!
Thanks,
Jason