Home
Support Forums

Can we make server-side 301 redirects of all 404 pages to homepage?

Hi,

I am trying to redirect all 404 pages to homepage. Although, I am using meta tag of redirection, but that doesn’t considered as 301 redirect.

Can we make something that we can redirect all 404 pages to homepage!

Hi @yousafblogger,

You can do something like:

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 301

This would go in your netlify.toml.

1 Like

then It will redirect all 200status pages to homepage. I just want 404 pages

Hi @yousafblogger,

No, it would work as expected because you’d not be adding force=true.

Just tried this. and it is not working!

Your site name could help me check this. Mind sharing one?

I changed the code a bit. and now it’s working. Thanks <3

Yeah, you had added /index instead of /index.html which is why it was not working.

I now added the main site url. and it’s working fine!

1 Like

@hrishikesh there’s an issue I am getting. most of the times I open my website it says too many redirects. and sometimes the directory urls also redirects to homepage!

Hi @yousafblogger,

I am not able to see this behaviour. Your home page seems to load fine. Is there a specific page which might be giving problems?

I removed the code and then the website works fine. Otherwise it said too many redirects

Well how do I test it then?