My site uses session cookies, which should be per session. So, I write the REMOTE_ADDR into the session cookie and want to check if it matches the current REMOTE_ADDR.
That's (A) cookie exists and (B) does not match IP address, then (C) set a variable "referer" with the cookie. I then put the variable into the log, crammed into referer:
So, the IP addresses match, but the second RewriteCond has a "!", so it should not have executed the RewriteRule. Why doesn't this work?
Apache config:
RewriteCond %{HTTP_COOKIE} "bot=\d+"
RewriteCond %{HTTP_COOKIE} !%{REMOTE_ADDR}
RewriteRule .* - [E=referer:%{HTTP_COOKIE}]
Code:
66.249.70.67 - - [15/Nov/2025:21:04:08 +0000] "GET /css.php?n=default&t=default HTTP/1.1" 200 5293 "bot=1_20251115130402_66.249.70.67" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.122 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"