2013-12-18 19 views
1

我正在一個網站上的所有網頁都在谷歌索引,但沒有一個網頁排名。一段時間後,該網站轉移到100%https,我懷疑由於htaccess代碼可能會出現某種重複的內容問題。這裏是我繼承了代碼:htaccess並可能導致重複的內容

RewriteEngine On   
RewriteBase/  
# 
#Redirect to wwww.example.com  
#rewritecond %{http_host} ^example.com [nc]  
#Rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]   
#  
#Remove the index.php after domain.com/index.phpl 
RewriteCond %{HTTPS} !=on 
RewriteRule ^/?(.*) https://www.example.com/$1 [R=301,nc] 
rewritecond %{THE_REQUEST} ^[c-t]{3,9}\ /index\.php\ HTTP/ [NC]  
Rewriterule ^(.*)index\.php /$1 [R=301]  

ErrorDocument 404 /404Error.php 

#Begin Redirects 

#FOR DIRECTORY REDIRECT 
RewriteCond %{QUERY_STRING} &?p=11&? 
RewriteRule ^exampleblog/$ http://www.example.com/new-york.php? [R=301,L] 

RedirectPermanent /about.html https://www.example.com/about.php 
RedirectPermanent /example-video.php https://www.example.com/ 
RedirectPermanent /brooklyn.php https://www.example.com/kings-county.php 

這是一個靜態的網站,使之指向所有頁面的htaccess的是生產一些奇怪的結果,如https://www.example.com/about.php/index.php

我試圖讓清理代碼該網址的https版本,例如https://www.example.com/,並且不會爲此創建重複的內容或任何其他問題。在此先感謝任何能夠指引我朝着正確方向的人。

回答

0

首先,您需要將一些L標誌添加到您的重定向規則中,以便重寫引擎不會繼續執行更深層次的規則。其次,RedirectPermanent是一個不同的模塊(mod_alias),它將使mod_rewrite和mod_alias都可以應用來應對相同的請求。所以,使用時只需mod_rewrite的,而不是:

RewriteEngine On   
RewriteBase/  

#Remove the index.php after domain.com/index.phpl 
RewriteCond %{HTTPS} !=on 
RewriteRule ^/?(.*) https://www.example.com/$1 [R=301,nc,L] 
rewritecond %{THE_REQUEST} ^[c-t]{3,9}\ /index\.php\ HTTP/ [NC]  
Rewriterule ^(.*)index\.php /$1 [R=301,L]  

ErrorDocument 404 /404Error.php 

#Begin Redirects 

#FOR DIRECTORY REDIRECT 
RewriteCond %{QUERY_STRING} &?p=11&? 
RewriteRule ^exampleblog/$ http://www.example.com/new-york.php? [R=301,L] 

RewriteRule ^about.html$ https://www.example.com/about.php [L,R=301] 
RewriteRule ^example-video.php$ https://www.example.com/ [L,R=301] 
RewriteRule ^brooklyn.php$ https://www.example.com/kings-county.php [L,R=301] 

您還可以卡在那裏非SSL規則,說不上是不是故意的或應該是HTTPS:

#FOR DIRECTORY REDIRECT 
RewriteCond %{QUERY_STRING} &?p=11&? 
RewriteRule ^exampleblog/$ http://www.example.com/new-york.php? [R=301,L]