Redirect to custom landing pages based on http referer


#1

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


#2

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 D. removed_email_address@domain.invalid