302 301 redirect custom HTML content

Eugene Piatenko eugene at piatenko.com
Thu Mar 23 11:59:55 UTC 2017


I'm trying to
1. send people to home page if they enter wrong place (404)
2. it works, but HTML content with headers is:

HTTP/1.1 302 Moved Temporarily
Server: nginx/1.10.3
Date: Thu, 23 Mar 2017 11:38:08 GMT
Content-Type: text/html
Content-Length: 161
Location: http://mysite/myhomepage.html
Connection: keep-alive

<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>

Is it possible to send custom page content?

My config:

server {
  listen 80;
    root /somewhere/mysite;
  location @redirect_to_home {
  error_page 302 /custom_302_page.html;
  return 302 /myhomepage.html;
  error_page 404 = @redirect_to_home;

Thanks for the advise!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170323/a83adc70/attachment-0001.html>

More information about the nginx mailing list