I don’t know how to write htaccess rules so I’m trying to piece together an htaccess file that would elegantly do two things:
1) rewrite all http://www.domain.com urls to domain.com
2) remove index.php while ensuring that index.php versions of the same URLs do not render separately and instead redirect/rewrite to their non-index.php equivalent
3) in a perfect word, condition 1 would work for http and https
So what I’ve pieced together so far, hopefully correctly, is this:
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
# Redirect www Requests
# ------------------------------
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$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]
</IfModule>Can any htaccess gurus out there tell me if this is correct?
Thanks!
John