0

In my .htaccess file I have a set of rules as follows:

RewriteRule ^dir/page1$ /bleh/docs/?id=12 [L,QSA]
RewriteRule ^dir/page2$ /bleh/docs/?id=13 [L,QSA]
RewriteRule ^dir/page3$ /bleh/docs/?id=14 [L,QSA]

Sometimes one of these rules may be accessed via a redirect from another site (referer). I would like to be able to append the referrer to the query string like this:

RewriteRule ^dir/page2$ /bleh/docs/?id=13&ref=%{HTTP_REFERER} [L,QSA]

However this does not seem to work.

What am I doing wrong?

3 Answers 3

3

If you're spelling it HTTP_REFERER (this is unclear due to edits), you're doing it correctly. If it isn't working at that point, it's because the referer isn't being supplied. (Which there are any number of reasons for; supplying it is at the browser's discretion.)

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

Comments

1

The variable for the referrer uses the common misspelling: HTTP_REFERER. See this cheat-sheet for some more variable names.

As far as I know, a rewritten URL won't remove the original Referer header though, so you should still be able to fetch it from your code without passing it as a query string parameter (provided it gives you access to the HTTP variables.)

Comments

0

A tested method that works for me and transfers the refferer through a 301 redirect. https://webmasters.stackexchange.com/questions/4665/

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.