Expression Engine - Removing index.php completely

2019-02-18 12:46发布

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条回答
ら.Afraid
2楼-- · 2019-02-18 13:32

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] 
查看更多
登录 后发表回答