2012-03-09 63 views
0

我想重定向頁面www.mysite.com/index.php到www.mysite.com/以防止重複的內容問題,但這會導致我可以因爲這會重定向http://www.example.com/administrator/index.phphttp://www.example.com/administrator/。我正在使用以下.htaccess重定向index.php到根影響管理員登錄

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/  
RewriteRule (([^/]+/)*)index\.(html?|php)$ http://www.example.com/$1 [R=301,L] 

但我不得不評論它登錄。請任何人都可以告訴我我哪裏錯了?

*我發現一個帖子的提示

RewriteCond %{REQUEST_URI} !^/administrator could go in the middle, would that be right? Sorry, new to all this :) 

回答

1

是的,你希望你的輸入鏈,看起來像這樣一個相似但不相同的問題:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/ 
RewriteCond %{REQUEST_URI} !^/administrator/ 
RewriteRule (([^/]+/)*)index\.(html?|php)$ http://www.example.com/$1 [R=301,L] 

你幾乎是正確的。其中的每個RewriteCond條件都固有地加在一起,並應用於它們之後的第一個RewriteRule。您可以按任意順序擁有兩個RewriteCond,並且必須滿足這兩個條件才能應用規則。