3

我有一個建立在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的索引?

+0

那麼當您向http://example.com/sitemap和http://example.com/index.php/sitemap/ – AllInOne

+0

發送請求時,您會看到什麼?@ AllInOne'example.com/sitemap'顯示站點地圖(並重定向到https)。 'example.com/index.php/sitemap'也顯示站點地圖(但*不*重定向到https) – kgrote

回答

1

這是怎麼回事,因爲該規則

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

是防止任何網址,這些網址被重定向到HTTPS開頭index.php

Google停止對網站編制索引的原因是因爲網站地圖是動態生成的,並使用當前的主機URL來創建鏈接。

由於/index.php/sitemap不再被重定向到HTTPS,因此Google將以HTTP開頭的URL編入索引,這對於Google而言是全新的,因爲它一直在索引到此時的HTTPS URL。