I would like someone to help me with an if-else statement in htaccess. I want htaccess to read a cookie and check if its value is equal to a certain value. If it evaluates to false, it should exclude redirection and prevent access to the requested folder. Maybe giving up on everyone would be better if evaluating returns false.
I know that the following code checks to see if the set cookie value is set. If it is not installed, it will execute the rewrite rule below it. But how can I tweak this string so that it checks if it is equal to a specific value?
RewriteEngine On RewriteCond %{HTTP_COOKIE} !^.*cookie_name.*$ [NC] RewriteRule .* http://www.google.com [NC,L]
What I would like, but in .htaccess style:
if ($_COOKIE['cookie_name'] != 'specific_value'){ //rewrite_rule or deny from all. }
regex cookies apache .htaccess mod-rewrite
Gillian lo wong
source share