开发者

How to set the referer on a rewrite rule?

开发者 https://www.devze.com 2023-01-04 07:33 出处:网络
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 UR

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.开发者_JS百科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]
0

精彩评论

暂无评论...
验证码 换一张
取 消