RewriteCond %{HTTP_COOKIE} not working

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-17-2006
jacob.miles@gmail.com
 
Posts: n/a
Default RewriteCond %{HTTP_COOKIE} not working

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.

  #2 (permalink)  
Old 05-17-2006
jacob.miles@gmail.com
 
Posts: n/a
Default Re: RewriteCond %{HTTP_COOKIE} not working

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.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0