I hope somebody may be able to help. I want to remove file extensions (.php) from my internal links but of course I need to first configure this in htaccess.
I believe that the correct code is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
however, when I add this code underneath / above the pre-existing code (to force https), nothing happens i.e. I still have to enter .php into the URL.
The htaccess file looks like this after adding the above code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://mysite/$1 [R=301,L]
Any ideas why this wouldn’t be working?
Thanks
I’ve been scouring the web but all posts say to simply add the rewrite code to htaccess, which unfortunately isn’t working.
I think the code isn’t playing well with the pre existing code to force https?
2
Answers
Try adding this snippet into your
.htaccess
fileI think the RewriteRule is to complex. I use the following for all my websites: