将403错误更改为410错误

所有50+页都在page2 site.com/page1/page2/

如何将403 Error更改为410 Error

 403 Error You are not authorized to access this page. This might be because: The page is not published The page is part of the CMS 

1.实现一个自定义的410错误页面

410代码表示所请求的资源不再可用,将不再可用。 这应该被用来当一个工作被有意删除,资源应该被清除。 在收到410状态码后,search引擎应该从索引中删除资源。

您可以使用RedirectMatch指令

 RedirectMatch 410 <appropiate rule> 

更新:

对于自定义错误页面 ,您可以添加:

 ErrorDocument 410 /410error.html 

如果您有多个文件,另一种方法是使用以下内容:

 # Is the request for a non-existent file? RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^page1/page2/(.*) /page1/page2/$1 [R=410,L] 

这将被用于所有被删除或不存在于特定目录中的页面。 请小心,因为覆盖404错误的默认行为