2

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 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.