URL displayed in browser does not change to new slug


I have a page at www.digitalwings.nz/recipients.html where the slug has been changed to www.digitalwings.nz/communities.html

I added a _redirect file in the root with the following entry: /recipients.html /communities.html and while it works, the URL in the browser address bar is not changing to show the new address.

I have read the instructions at Redirect options | Netlify Docs and believe the first example (301) represents my implementation. I have also tested in the playground at Netlify's playground and got a "Yay! All redirects are valid.

I’m at a loss to understand why the URL in the browser does nor change to the new slug: www.digitalwings.nz/communities.html when I enter www.digitalwings.nz/recipients.html in the browser?

Thanks for your help

hi david, can you share the code on your redirects file please?

Hi, here attached is my _redirects file.

(Attachment _redirects is missing)


My attached file was rejected so here is a copy/paste of the contents

/recipients.html /communities.html

The filename is: _redirects (no extension)


Hey @firstfruits

You said it is in the root. As mentioned in the Redirects and Rewrites documentation

Save a plain text file called _redirects without a file extension to the publish directory of your site.

Is the root the directory that is published?

Yes, same place as the _headers, GIT readme.md and all other folders css, fonts, js and so on

Do both recipients.html and communities.html exist?

Redirects do not trigger if there is content—the content is returned. So if recipients.html exists you have two options

Two options:

  1. Delete the recipients.html file which means no need to force the redirect; OR
  2. Leave the recipients.html file and force the redirect as below
    /recipients.html   /communities.html   301!

In this case the ! is the force. In netlify.toml syntax it is

  from = "/recipients.html"
  to = "/communities.html"
  status = 301
  force = true

Only the communities.html files exist, it was renamed from recipients.html and on checking there are no backups of the old recipients.html file. The redirect is only required for users who have bookmarked or otherwise saved the old recipients.html url

Are you seeing that redirects are processed in the latest deploy?


Not exactly that format but the deploy log does indicate post processing rules completed: https://i.imgur.com/KJTJSFR.png - Sorry, I’ve just checked and quoted the wrong area. They have processed correctly: https://i.imgur.com/0LNE0Qy.png

Maybe I’ve misunderstood this paragraph on the Netlify docs page, specifically the last sentence:

301 (default) : permanent redirect code. Tells the client that the address for this resource has permanently changed, and any indexes using the old address should start using the new one. The URL in the browser address bar will display the new address."

I don’t believe you have misunderstood.

Take this demo: sparkly-moonbeam-2a8faf.netlify.app (GiHub coelmay/redir) that contains the following _redirects.

/page2.html  /new-page.html
/page3.html  /new-page.html
/page4.html  /new-page.html  200
/page5.html  /new-page.html  301!
  • page2.html exists, so the redirect does not trigger, and the content of page2.html is returned, not new-page.html, and the URL shows page2.html.
  • page3.html does not exist, so the redirect triggers. The content of new-page.html is returned and the URL shows new-page.html. A 301
  • page4.html does not exist but is rewritten. The content of new-page.html is returned but the URL shows page4.html not new-page.html.
  • page5.html exists, but the content of new-page.html is shown and the URL shows new-page.html because the redirect is forced.

Thanks for the demo, explains it in a way that is easy to understand. So my setup would be the second one in the example demo, * page3.html does not exist, so the redirect triggers. The content of new-page.html is returned and the URL shows new-page.html . A 301

In my case, “new-page.html” is returned but the URL is not showing “new-page.html” rather it shows “page3.html”.

Have you confirmed in the current published deploy that recipients.html does not exist? Check this by downloading the deployed files e.g (your deploy possibly isn’t locked):

I ask because… When I run

$ curl -IL https://www.digitalwings.nz/communities.html

# The response includes
HTTP/2 200
date: Wed, 30 Mar 2022 04:20:05 GMT
x-nf-request-id: 01FZCWSBC6F13BWZPAQN0QMYEW
content-length: 66817

compared to

$ curl -IL https://www.digitalwings.nz/recipients.html

# The response includes
HTTP/2 200
date: Wed, 30 Mar 2022 07:38:47 GMT
x-nf-request-id: 01FZCWSMXH2CPW5QKPJSES525F
content-length: 66715

noting the date and content-length are different which means different content is being returned.


recipients.html is in the ZIP, but not in my local folder or reported in the desktop git client. I’ll have to find out why files deleted locally are not deleted from git on the web. Thank you for your assistance and persistence with this issue. I expect it to work as soon as I get that rogue file deleted. :smile: