Using Apache 2.4’s htaccess file, some redirects and headers are configured.
How can I configure it to send a specific header to all but specific IP?
Something like this wrong code:
RewriteCond %{REMOTE_ADDR} ^1.2.3.4$
Header always set BLAH "is blah"
RewriteCond %{REMOTE_ADDR} !^1.2.3.4$
Header always set BLAH "is no so blah!"
2
Answers
In Apache 2.4 there is this expression option detailed in here
Basically do
You can set an environment variable if the request originates from a specific IP address(es) and set the header conditionally when that variable is or is not set using the
env=
argument to theHeader
directive.For example, using mod_setenvif and mod_headers:
Works with both Apache 2.2 and 2.4