When I use this in my htaccess file:
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteRule ^(.*)$ http://www.site.com/ [R=301]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)$ $1.php [NC,L]
If you go to site.com without www it redirects to www.site.com/.php instead of www.site.com.
Any thoughts?
Thanks!
Maybe it's browser's cache from your old .htaccess? Try to empty the cache, or use other browser (or maybe Priavte Browsing).
I think at the root SCRIPT_FILENAME would be "/", which would not be considered a valid file and trip the !-f causing the rule to be applied.
Since the / is a character caught by the regex it will rewrite it to www.site.com/.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With