Mauro
Mauro

Reputation: 131

set referrer header using query string on apache configuration

I need to take a parameter from the query string and set it in the referrer header in the Apache configuration file. Do you know if this is possible?

I'm able to do the same with the cookies but I need to do it using the query string.

setEnvIfNoCase ^Cookie$ "(referrer=\w*:\/\/\w*)" HTTP_MY_COOKIE=$1
setEnvIfNoCase HTTP_MY_COOKIE "(http:\/\/.*\.\w*)" REFERRER=$1
RequestHeader set Referer %{REFERRER}e

Regards

Upvotes: 2

Views: 7844

Answers (1)

Mauro
Mauro

Reputation: 131

The solution was quite simple. setEnvIfNoCase or setEnvIf can't use the query string so is not possible to use the same trick i used for the cookies, the solution is a combination of RewriteCond with RewriteRule like in the example below:

RewriteCond %{QUERY_STRING} referrer=(.*)
RewriteRule ^/ - [env=REFERRER:%1]
RequestHeader set Referer %{REFERRER}e

i answered to my question so another user (if exist) with the same question can find an starting point.

Upvotes: 7

Related Questions