0

I googled and searched on stack over flow but i not found my answer. in Google webmaster Tools, My site have 58,842 Not Found[404] URL Errors. I want all 404 pages redirect to home page with 410 status code using the .htaccess file. I mean before redirecting to home page, I want visitors or Search Engines redirected to home page and get 410 status code. I want tell to Search Engines that, the 404 page was permanently deleted[410] and redirect to home page. For example...

step-1 Visitors or Search Engines visits this url. this is 404 page.
https://example.com/some-url-of-my-blog

step-2 Search Engines get HTTP/1.1 410 Gone [status code 410]
step-3 Visitors or Search Engines redirected to home page. That's it.

Is it possible in .htaccess file. Please anyone solve this.

Gul Noor
  • 15
  • 4

1 Answers1

0

It sounds like you are really just wanting the 410 redirect on any pages and directories that do not exist.

For most cases something like this should work fine

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,R=410]
WiththeWind
  • 153
  • 1
  • 9
  • But I also want 410 redirect to home page. 1st tells to search engine that the 404 page is gone [HTTP Status code is 410] and then 410 redirect to homepage. – Gul Noor Nov 24 '18 at 03:59
  • I want more to clearly explain it. 1-Server send 410 status code **[to the browser or crawler]** for 404 error page and then 410 error page redirect the browser or search crawler to the home page. – Gul Noor Nov 24 '18 at 04:23