Hello -
We have removed the need for index.php within EE using (within .htaccess):
# strip index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]We noticed a duplicate content issue where some links to the same page had a trailing slash while others did not.
We added:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]However, this redirects WITH the index.php in the URL.
This behavior makes sense in that the actual request always has the index.php - We are just saying (via .htaccess) if it not there to add it to the request, but we are not enforcing it’s absence.
I believe I need some help making sure index.php is taken away if it is present in the request. (Use a redirect if it exists)
Perhaps this should be part of an extension rather than within htaccess? (In other words, part of the application code rather than web server config).
The order of rewrite rules is important. You need to put the:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]Above the:
# strip index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]Generally I try and keep the index.php removal rule last or anything that redirects before other rules that do not redirect - it just depends.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.