2012-06-21 42 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