Hope someone can help. I want to remove the file extension (.php) from internal links, but of course I need to configure it in htaccess first.
I believe the correct code is
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ .php [NC,L]
However, when I add this code below/above the pre-existing code (forcing https), nothing happens, i.e. I still need to put the .php Enter the URL.
After adding the above code, the htaccess file will look like this:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ .php [NC,L] RewriteCond %{SERVER_PORT} !=443 RewriteRule ^(.*)$ https://mysite/ [R=301,L]Any ideas why this doesn't work?
Thanks
I've been searching online but all posts say to just add the rewrite code to htaccess, unfortunately this doesn't work.
I don't think this code plays well with the existing code that forces https?
P粉1949190822024-04-05 12:23:24
I think RewriteRule is too complex. I use the following for all my sites:
# append .php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule .* rrreee.php [L] # fallback to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L]