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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
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
This topic is locked and can not be replied to.