【问题标题】:Accessible Index Page Configured wrong - How to fix?可访问索引页面配置错误 - 如何修复?
【发布时间】:2019-03-14 11:19:10
【问题描述】:

我运行了一个通过SiteCheckerPro 创建的网站。我看到一个“严重错误”,但我不确定如何修复它。错误是“URL 漏洞:配置错误”

报告说:

“网址漏洞

搜索引擎会看到您的https://website.co.ukhttps://website.co.uk/index.html(或https://website.co.uk/index.php) 作为不同的页面。

如果您没有明确告诉 Google 哪个网址是规范的,Google 会为你做出选择,或者可能认为他们都是平等的 重量,这可能会导致不良行为。”

我明白它在告诉我什么,但我不知道如何解决它。

我添加了一个规范标签

<link rel="canonical" href="https://website.co.uk/" />

我添加了一些 htaccess 规则来将 www 重定向到非 www 和 http 到 https

#www > non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

#http > https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

我不知道我还能做些什么来修复这个错误?

【问题讨论】:

    标签: .htaccess redirect url-rewriting url-redirection


    【解决方案1】:

    将此添加到htaccess 文件中解决了该问题。

    Redirect 301 /index.html https://website.co.uk/
    Redirect 301 /index.php https://website.co.uk/
    

    错误不再显示在报告中。

    【讨论】:

    • 这当然是正确的,尽管两条规则之一就足够了。这是建议和显然需要的直接实施。这里没有魔法。
    【解决方案2】:

    把它放在你的 htaccess 中, 它会重定向 index.html 或 index.php

    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]
    
    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)index.html$ http://www.example.com/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2020-11-04
      • 2018-06-07
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多