Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess 301如果找不到页面,则重定向到主页_Apache_.htaccess_Http Status Code 301 - Fatal编程技术网

Apache .htaccess 301如果找不到页面,则重定向到主页

Apache .htaccess 301如果找不到页面,则重定向到主页,apache,.htaccess,http-status-code-301,Apache,.htaccess,Http Status Code 301,我已经清理了我的网站,丢弃了很多页面。我现在有100页的网站剩下10页,全部是静态html。我想删除网页的任何请求301重定向到主页,但无法找出.htaccess规则 我怀疑是否有比在中手动列出90页更好的方法 redirect 301 /somedeletedpage.htm http://www.example.com/ 除非删除的90个页面具有一些可以重新执行的常见特征。您不想对其执行301操作,否则这将是一个错误的代码,因为缺少的页面尚未移动到主页的位置。你应该为404或410提供服务

我已经清理了我的网站,丢弃了很多页面。我现在有100页的网站剩下10页,全部是静态html。我想删除网页的任何请求301重定向到主页,但无法找出.htaccess规则

我怀疑是否有比在
中手动列出90页更好的方法

redirect 301 /somedeletedpage.htm http://www.example.com/

除非删除的90个页面具有一些可以重新执行的常见特征。

您不想对其执行301操作,否则这将是一个错误的代码,因为缺少的页面尚未移动到主页的位置。你应该为404或410提供服务。你可以使用一个自定义404,这样你的用户就可以有一些到现在页面的链接。

这对搜索引擎排名不好吗?@tututul-不,如果有什么好处的话,那对搜索引擎排名会更好,特别是410-因为这是正确的回答(内容已经消失了)。正如多米尼克所说,这更好,301主页上的所有内容都可能是seo噩梦,虽然从100减少到10也有点奇怪,但这超出了这个问题的范围。是否最好检查请求的页面是否存在,然后提供,如果不存在,然后重定向到主页?@tutuul-否,因为这可能会阻止404访问从未存在过的页面。