【问题标题】:RewriteRule Preventing Google from Indexing SiteRewriteRule 阻止谷歌索引站点
【发布时间】:2013-11-04 16:58:28
【问题描述】:

我有一个基于 ExpressionEngine (EE) 的网站。默认情况下,EE 要求index.php 出现在 URL 的第一段中。为了美化我的 URL,我使用了 .htaccess RewriteRule:

# Remove index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

整个网站也使用 SSL,我使用另一个 RewriteRule 来完成:

# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

最近,客户要求将他们的 RSS 提要移至 Feedburner。但是,Feedburner 不喜欢 https URL,所以我不得不修改我的 SSL RewriteRule 以不在提要页面上强制 SSL:

# Force SSL except on RSS feeds
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/feeds/ [NC]
RewriteCond %{REQUEST_URI} !^/index\.php [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

所以我的整个 .htaccess 文件如下所示:

RewriteEngine On
RewriteBase /

# Force SSL except on RSS feeds
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/feeds/ [NC]
RewriteCond %{REQUEST_URI} !^/index\.php [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

# Remove index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

但是,当我将提要规则添加到 .htaccess 文件中后,Google 就停止了对该站点页面的索引。提交给 Google 的站点地图 URL 是 /index.php/sitemap,所以我认为 index.php 在这里发挥了作用。

如何调整我的 .htaccess 文件以在我的提要页面上允许 SSL,但又不会弄乱 Google 的索引?

【问题讨论】:

  • 那么当您向example.com/sitemapexample.com/index.php/sitemap 发出请求时,您会看到什么
  • @AllInOne example.com/sitemap 显示站点地图(并重定向到 https)。 example.com/index.php/sitemap 还显示站点地图(但重定向到 https)

标签: .htaccess expressionengine google-search-console feedburner


【解决方案1】:

发生这种情况是因为规则

RewriteCond %{REQUEST_URI} !^/index\.php [NC]

阻止任何以 index.php 开头的 URL 被重定向到 HTTPS。

Google 停止对该站点编制索引的原因是站点地图是动态生成的,并使用当前主机 URL 来创建链接。

由于 /index.php/sitemap 不再被重定向到 HTTPS,Google 正在索引以 HTTP 开头的 URL,这对 Google 而言是全新的,因为它一直在索引 HTTPS URL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    • 2013-03-10
    • 1970-01-01
    相关资源
    最近更新 更多