将404 [未找到]错误重定向到主页,并且在重定向到首页之前,使用.htaccess告知搜索引擎404页面已消失[410]

问题描述:

我在流量上搜索并搜索了堆栈,但没有找到答案。 Google网站管理员工具中的
,我的网站有58,842找不到[404] URL错误。我希望所有的404页面使用.htaccess文件重定向到带有410状态代码的主页。我的意思是在重定向到主页之前,我希望访问者或搜索引擎重定向到主页并获得410状态代码。我想告诉搜索引擎,该404页已被永久删除[410],并重定向到主页。例如...

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...

步骤1访客或搜索引擎访问此URL。这是404页。

https://example.com/ some-url-of-my-blog

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

步骤2搜索引擎获得HTTP / 1.1 410消失[状态代码410]

步骤3将访问者或搜索引擎重定向到主页。就是这样。

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.

.htaccess文件中是否可能。请任何人解决。

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

听起来您真的只是想在所有不存在的页面和目录上使用410重定向。 。

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]