Rewrite http_referer
Maxim Dounin
mdounin at mdounin.ru
Tue Mar 31 01:39:23 MSD 2009
Hello!
On Mon, Mar 30, 2009 at 05:16:00PM -0400, n3uro5i5 wrote:
> Hi, i want to catch request from a determinate referer website and redirect it to my root path.
>
> I try this:
>
> if ($http_referer ~* "my_referer.com"){
> rewrite (.*) / redirect;
> }
>
> But when i did't firefox say me that the request is in a neverending loop.
> So i need to rewrite the request referer header before redirect it.
>
> I tried it like this:
>
> if ($http_referer ~* "my_referer.com"){
> rewrite (.*) / reset_header redirect;
> }
>
> location /reset_header{
> proxy_set_header Referer "";
> rewrite (.*) / redirect;
> }
>
> But i don't get any results.
>
> Any suggestion? Thanxs!!
You can't change referer, it's set by browser. You should avoid
redirect on destination page instead. E.g.
location = / {
# no redirect for /
...
}
location / {
if ($http_referer ...) {
rewrite ^ / redirect;
}
...
}
Maxim Dounin
More information about the nginx
mailing list