Forum Moderators: phranque
Some time ago this forum's members were kind enough to help me figure out how to rewrite example.com to www.example.com. I ended up with the following code which works perfectly:
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]
Over the past few months I've occasionally tried to address my other remaining issue which is to rewrite www.example.com/index.php to www.example.com but I'm going to have to admit defeat, no matter what I try nothing seems to work. What I have at the moment is the following:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule /index\.php$ http://www.example.com/$1 [R=301,L]
Does anyone see anything immediately which I'm doing wrong?
Many thanks in advance for any advice.
Kind regards,
Mac
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule /index\.php$ http://www.example.com/$1 [R=301,L]
This should be the working version:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
Simple little adjustments:
No preceding / in the .htaccess on the left side.
No need for the back-reference $1 on the right side.
Hope this helps.
Justin