Forum: NGINX Redirect to custom landing pages based on http referer

2974d09ac2541e892966b762aad84943?d=identicon&s=25 justink101 (Guest)
on 2014-06-05 09:15
(Received via mailing list)
Is it possible using nginx to essentially look at the http referer
header,
and if its set to a specific value, and the page is index.html or /,
redirect to a custom landing page.

For example:

# Psuedo code
if($page = "index.html" and $http_referer ~* (www\.)?amazon.com.*) {
     rewrite ^ "our-amazon-landing-page.html" permanent;
}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250656,250656#msg-250656
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2014-06-05 09:36
(Received via mailing list)
On Thu, Jun 05, 2014 at 03:15:26AM -0400, justink101 wrote:

Hi there,

> Is it possible using nginx to essentially look at the http referer header,
> and if its set to a specific value, and the page is index.html or /,
> redirect to a custom landing page.

Yes.

With a few other assumptions:

  location = /index.html {
    if ($http_referer ~* (www.)?amazon.com) {
      return 301 /our-amazon-landing-page.html;
    }
  }

That doesn't scale much beyond one match; if you need that, use a "map".

  f
--
Francis Daly        francis@daoine.org
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.