I want to check if {HTTP_HOST} is in {HTTP_COOKIE} and if not redirect to one cookie value.
The cookie is correctly set with : (cookie name is DST_HOST)
RewriteCond %{HTTP_COOKIE} !DST_HOST [NC]
RewriteRule ^ - [CO=DST_HOST:%{HTTP_HOST}:mydom.x]
Now I'm struggling with the RewriteCond statement as we cannot compare two variables.
I can easily test if the cookie is set with :
RewriteCond %{HTTP_COOKIE} DST_HOST
But I cannot do the variable comparaison test. The idea would be something like :
RewriteCond %{HTTP_COOKIE} !DST_HOST=%{HTTP_HOST}
The right portion of the statement isn't evaluated we can only put static contents here.
I then tried with something found in Apache configuration guide :
RewriteCond expr "! %{HTTP_COOKIE} -strmatch '*%{HTTP_HOST}*'"
But it doesn't evaluate the variables (I'm running Apache 2.4, maybe this only works with Apache 2.5)
Any help would be greatly appreciated.
Kind regards,
Jean-Damien
question from:
https://stackoverflow.com/questions/65952258/apache-match-http-host-in-http-cookie 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…