2012-06-21 43 views
3

我一直在我的.htaccess文件中使用下面的代碼一段時間,以使EE網址工作,而不需要URL中的index.php。我發現雖然我從爬行工具獲得一些報告,但我得到重複內容,因爲/ lorem/ipsum /也彈出某處作爲/index.php/lorem/ipsum/。表達式引擎 - 完全刪除index.php

我知道這可能是由於鏈接中引用index.php的雜散鏈接造成的,但我想通過強制index.php排除鏈接來彌補差距。我看了一下,但我似乎無法找到如何強制它。

RewriteEngine On 
RewriteBase/

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 

回答

8

當然可以。

# Enable Rewrite Engine 
# ------------------------------ 
RewriteEngine On 
RewriteBase/

# Redirect index.php Requests 
# ------------------------------ 
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC] 
RewriteCond %{THE_REQUEST} ^GET 
RewriteRule ^index\.php(.+) $1 [R=301,L] 

# Standard ExpressionEngine Rewrite 
# ------------------------------ 
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

太棒了,感謝您花時間回答我的問題。完美的作品! – Leonard