set referrer header using query string on apache configuration

匆匆过客 提交于 2019-12-12 09:04:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!