【发布时间】: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/sitemap 和example.com/index.php/sitemap 发出请求时,您会看到什么
-
@AllInOne
example.com/sitemap显示站点地图(并重定向到 https)。example.com/index.php/sitemap还显示站点地图(但不重定向到 https)
标签: .htaccess expressionengine google-search-console feedburner