2013-12-11 28 views
1

我有以下問題:
我需要從的index.php重定向(301)的首頁,但也有重寫規則:
如何與htacess重定向時有重寫規則

RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule (.*) index.php 

而且有重定向循環當我添加一行:

Redirect 301 /index.php http://example.com/ 

我怎麼能做到這一點不改變重寫規則?的.htaccess不夠清晰,我

回答

0

讓你的規則是這樣的:

RewriteCond %{THE_REQUEST} /index\.php [NC] 
RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE] 

RewriteCond %{REQUEST_URI} (\.html?|\.php|/[^.]*)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule^index.php [L]