我有一個建立在ExpressionEngine(EE)上的網站。默認情況下,EE需要index.php
出現在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,這是我與其他重寫規則完成服務:
# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
最近,客戶要求移動他們的RSS提要給Feedburner。然而,Feedburner的不喜歡https網址,所以我不得不改變我的SSL重寫規則不強制對飼料的網頁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]
但是,只要將feeds規則添加到.htaccess文件,Google就會停止對網站的頁面編制索引。提交給Google的網站地圖網址是/index.php/sitemap
,所以我認爲index.php
在這裏扮演了角色。
如何調整我的.htaccess文件以允許在我的提要頁上使用SSL,但不會搞亂Google的索引?
那麼當您向http://example.com/sitemap和http://example.com/index.php/sitemap/ – AllInOne
發送請求時,您會看到什麼?@ AllInOne'example.com/sitemap'顯示站點地圖(並重定向到https)。 'example.com/index.php/sitemap'也顯示站點地圖(但*不*重定向到https) – kgrote