问题
I have an interesting problem.
I need to implement rewrite rules based on if a cookie is there or not. Thats easy enough, the below rewrite rule will check if the cookie is there and if it is it will not redirect, equally if it is not there it will redirect.
RewriteCond %{HTTP_COOKIE} !^.mycookie.$ [NC]
All good so far. Now what I want to do is, if the cookie is present and the value is a specific value then I want to redirect.
I have tried the following combinations which I thought would work but neither do:
RewriteCond %{HTTP_COOKIE} !^.*mycookie.*$ [NC]
RewriteCond %{HTTP_COOKIE} mycookie='XX' [NC]
RewriteCond %{HTTP_COOKIE} !^.*mycookie.*$ [NC] [OR]
RewriteCond %{HTTP_COOKIE} mycookie='XX' [NC]
The rules for my rewrite conditions in summary are:
- If the cookie is there do not redirect unless the value is XX in which case follow the redirect
- If the cookie is not there redirect
Thanks in advance
来源:https://stackoverflow.com/questions/6943968/apache-rewrite-rules-for-cookies