I have the following problem: I use a script that saves the referer URL. I want this URL to one of my own URLs. So let's say a users access the page http://example.com/page1 I want to rewrite that URL to http://example.com/page2 and safe the referer on that page.
I don't want to do that with a PHP script as otherwise I would have to extend that script each time I want to track a new referer. I already tried these rewrite rules:
RewriteRule ^page1$ /page2 [R=301,QSA,NC]
RewriteRule ^page1$ /page2 [L,R=301,QSA,NC]
The rewrite works, but the request parameter referer is missing. Do I have to use another stauts code than 301 or is there any other error in my rewrite. Is it even possible to set the referer in a rewrite rule?
Using the R flag causes an external redirect. If you just want an internal rewrite, omit the R flag:
RewriteRule ^page1$ /page2 [QSA,NC]