Expression Engine - Removing index.php completely

a 夏天 提交于 2019-12-19 09:41:01

问题


I've been using the below code in my .htaccess file for a while to make the EE URLs work without needing index.php in the URL. What I've found though it that I'm getting some reports from crawling tools that I'm getting duplicate content as /lorem/ipsum/ is also popping up somewhere as /index.php/lorem/ipsum/.

I know that this is likely a result of a stray link referencing the index.php in the URL but I'd like to close up the gaps by forcing index.php out of the links. I've had a look around but I can't seem to find how to force it out.

RewriteEngine On
RewriteBase /

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

回答1:


Sure thing.

# 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] 


来源:https://stackoverflow.com/questions/11142853/expression-engine-removing-index-php-completely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!