Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
.htaccess重定向-更新站点(301是否合适?)_.htaccess_Redirect_Seo - Fatal编程技术网

.htaccess重定向-更新站点(301是否合适?)

.htaccess重定向-更新站点(301是否合适?),.htaccess,redirect,seo,.htaccess,Redirect,Seo,我在更新我的网站时遇到了一个问题,谷歌搜索结果显示了到旧页面的链接,现在是404,其中一些甚至包含不推荐的内容 我的问题是关于301的使用。旧页面具有深度嵌套的页面,如下例所示: www.site.com/category/subjects/subject_b.html 它出现在谷歌上,对“subject_b”有一个非常具体的描述,这对我来说不是最好的 我一直在研究的新布局意味着曾经在“/category/subjects/subject_b”下的内容现在可以在一个页面(www.sit

我在更新我的网站时遇到了一个问题,谷歌搜索结果显示了到旧页面的链接,现在是404,其中一些甚至包含不推荐的内容

我的问题是关于301的使用。旧页面具有深度嵌套的页面,如下例所示:

    www.site.com/category/subjects/subject_b.html
它出现在谷歌上,对“subject_b”有一个非常具体的描述,这对我来说不是最好的

我一直在研究的新布局意味着曾经在“/category/subjects/subject_b”下的内容现在可以在一个页面(www.site.com/subjects.html)中找到,同时还有假设的subject_a和subject_c

我这样重定向旧页面会是错误的吗

    redirect http://www.site.com/category/subjects/subject_a.html http://www.site.com/subjects.html
    redirect http://www.site.com/category/subjects/subject_b.html http://www.site.com/subjects.html
    redirect http://www.site.com/category/subjects/subject_c.html http://www.site.com/subjects.html
另外,我将如何处理包含google描述的页面,这些页面的内容不在新EqualClient页面上

如果有人能为我解释一下,或者给我指出一个正确的方向,让我在哪里可以读到更多关于它的信息,我会很高兴的

我这样重定向旧页面会是错误的吗

    redirect http://www.site.com/category/subjects/subject_a.html http://www.site.com/subjects.html
    redirect http://www.site.com/category/subjects/subject_b.html http://www.site.com/subjects.html
    redirect http://www.site.com/category/subjects/subject_c.html http://www.site.com/subjects.html
您将删除
http://www.site.com
零件。这应足以:

Redirect 301 /category/subjects/subject_a.html /subjects.html
Redirect 301 /category/subjects/subject_b.html /subjects.html
Redirect 301 /category/subjects/subject_c.html /subjects.html
甚至:

RedirectMatch 301 ^/category/subjects/subject(.*) /subjects.html
包括所有3个

如果您有多个域都指向同一文档根,并且实际上需要匹配特定域的路径,则可以使用mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?site.com$ [NC]
RewriteRule ^/?category/subjects/subject(.*) /subjects.html [L,R=301]

您好,谢谢您的快速回复!另外:你对搜索结果的描述有什么看法(当谷歌机器人被301'd和我通过网站管理员工具重新编制索引时,它会改变这些吗)?