问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/20220059/set-referrer-header-using-query-string-on-apache-configuration