This is a discussion on RewriteCond %{HTTP_COOKIE} not working within the Apache Web Server forums, part of the Web Server and Related Forums category; Hello. I'm trying to create different views of my website based on a cookie. I've confirmed that the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello. I'm trying to create different views of my website based on a
cookie. I've confirmed that the cookie is being set correctly, but when I try to access a page my rewrite rule isn't matching: # dev view RewriteCond %{HTTP_COOKIE} ^__view=dev$ RewriteRule ^(.*)$ dev/$1 [L] When I comment out the RewriteCond rule, and access http://mywebsite/ it works fine, rewriting the url to the dev/ subdirectory. When I uncomment it, apache says I don't have permission to access / on this server. I've checked in Firefox's preferences panel and view php that the __view cookie is present and that the value is dev. I'd appreciate any help - this is for a client and I'm past the deadline. |
|
|||
|
I solved the problem. It turns out it was not the rewrite rule. I
don't understand exactly how this works, but the script setting the cookie was in a subdirectory, and the .htaccess file with the RewriteCond rule was in the parent, so for some reason the cookie wasn't there when the .htaccess file looked for it, so the rule was legitimately failing. I checked this with a script in the parent directory - the cookie wasn't there, though it was there in a script in the subdirectory. I guess I don't quite understand how cookies are mapped to domains - I suspect that the other rewrites I'm doing are having an effect on what domain the cookie is stored under. In short, for the moment the solution is to move the cookie-setting script into the same directory as the .htaccess file looking for it. |