Permanent Redirect on nginx

Mumanyi, Bravismore bmumanyi at
Fri Apr 29 07:33:04 UTC 2016

Francis, your config did magic! Kudos...

However, I just wondering the cause for the redirect URL having two trailing slashes "//" i.e. ""? The links seem to work though.

The two server blocks are as follows.

server {
    listen 80;
    listen 443 ssl;
    return 301 $scheme://$request_uri;

server {

  listen 80;
  listen 443 ssl;
  root /usr/share/nginx/atom;

  # _ means catch any, but it's better if you replace this with your server
  # name, e.g.
  #server_name _;


-----Original Message-----
From: nginx [mailto:nginx-bounces at] On Behalf Of Francis Daly
Sent: 28 April 2016 18:15
To: nginx at
Subject: Re: Permanent Redirect on nginx

On Thu, Apr 28, 2016 at 02:47:03PM +0000, Mumanyi, Bravismore wrote:

Hi there,

> My org has changed domain from to I intend to effect a permanent redirect on Nginx.

Have two server{} blocks.

The one with "server_name new-name;" should be the fuller one, doing everything you want.

The other should have "server_name old-name;" and "return 301 http://new-name$request_uri;" and not a lot more.

Francis Daly        francis at

nginx mailing list
nginx at

More information about the nginx mailing list