How can I make my website redirect to another based on a cookie with .htaccess?


How can I make my website redirect to another based on a cookie with .htaccess?



I'm trying to do this with .htaccess. So what I did was set a cookie named "domain" with the website I'm redirecting to. In my .htaccess file I have this

RewriteEngine on RewriteCond %{HTTP_COOKIE} domain=([^;]+) [NC] RewriteRule ^(.*)$ %1/$1 [L] 

I got that code from a Google search. It's supposed to reditect http://mywebsite.com/something to http://someotherwebsite.com/something. But it's not working. Any tips?

Edit: I still haven't been able to get it to work. A temporary solution I'm using is using PHP to get the cookie value and redirect that way.




mode_rewrite: example.com/münster -> example.com/index.html?city=münster

1:



.htaccess issue
I would turn on RewriteLog on a fairly high level and see whether that provides a clue..
htaccess rewriterule question


.htaccess foobar.html -> foobar.php


91 out of 100 based on 71 user ratings 871 reviews