Welcome! Log In Create A New Profile

Advanced

301 redirect with custom content problem

Robert Mueller
November 29, 2012 08:54PM
Hi

I'm trying to setup a permanent redirect from http -> https. As a
fallback for a small number of users where https is blocked, I'd like to
show them a message.

I thought an error_page 301 handler would allow me to do this, but I'm
having trouble making it work:

server {
listen *:80 default;
rewrite ^ https://example.com$uri permanent;
}

error_page 301 /foo/bar/301.html;

Seems to confuse the redirect. It seems to completely replace the
redirect Location header with foo/bar/301.html rather than actually
serving that content.

I tried some alternatives like:

error_page 301 @301;
location @301 {
root /foo/bar/;
try_files $uri /301.html;
}

But again, it replaces the Location header adding /301.html on the end
of the redirect hostname rather than actually serving the 301.html
content.

Is there a reliable way to return custom content for a 301 redirect in a
way that doesn't affect the redirect location itself? I'm using nginx
1.2.4.

--
Rob Mueller
robm@fastmail.fm

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

301 redirect with custom content problem

Robert Mueller November 29, 2012 08:54PM

Re: 301 redirect with custom content problem

Maxim Dounin November 30, 2012 02:44AM

Re: 301 redirect with custom content problem

Robert Mueller December 04, 2012 12:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 44
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 214 on March 20, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready