Welcome! Log In Create A New Profile

Advanced

Re: Rewrite http_referer

Maxim Dounin
March 30, 2009 05:39PM
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
Subject Author Posted

Rewrite http_referer

n3uro5i5 March 30, 2009 05:16PM

Re: Rewrite http_referer

Maxim Dounin March 30, 2009 05:39PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready