Expression Engine - 完全移除index.php

3
我已经在我的.htaccess文件中使用以下代码一段时间,使EE网址无需在URL中包含index.php即可正常工作。但是,我发现一些爬虫工具报告说我出现了重复内容,因为/lorem/ipsum/也会在某个地方出现为/index.php/lorem/ipsum/。
我知道这很可能是由于一个杂散的链接引用了URL中的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]
1个回答

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] 

太棒了,感谢您抽出时间为我解答。完美运作! - Leonard

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接