How can I set my root directory based on a cookie?
Posted
by
Kacey
on Stack Overflow
See other posts from Stack Overflow
or by Kacey
Published on 2014-06-04T21:22:50Z
Indexed on
2014/06/04
21:24 UTC
Read the original article
Hit count: 145
.htaccess
I'm attempting to use my htaccess file to set my root folder based on a cookie that is set through the website. Unfortunately, I haven't been able to find any information on how to do this. Here is what I have tried doing, which I know is incorrect, but it was the best I could find to work with.
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.(int|com)$ [NC,OR]
RewriteCond %{REQUEST_URI} !^/s3i.flat/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} s=n2014 [NC]
RewriteRule ^(.*)$ /s3i.flat/$1
RewriteRule ^(.*)$ /s3i.2014/$1
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.(int|com)$ [NC]
RewriteCond %{HTTP_COOKIE} s=n2014 [NC]
RewriteRule ^(/)?$ s3i.flat/ [L]
RewriteRule ^(/)?$ s3i.2014/ [L]
What I'm trying to do is use the s3i.flat
directory if the cookie named s
is equal to n2014
, and the other directory if the cookie is not set, or does not equal that. Is anyone aware of a way that this can be done? Thanks in advance.
© Stack Overflow or respective owner