Page 1 of 1

Htaccess help remove .php

Posted: Sat Sep 16, 2023 2:49 pm
by Manchester_man
Hi,

I know this isn't related to the software, however I hope somebody may be able to help. I want to remove file extensions (.php) from my links but of course I need to first configure this in htaccess.

I am aware 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 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.org/$1 [R=301,L]

Any ideas why this wouldn't be working?
Thanks

Re: Htaccess help remove .php

Posted: Sat Sep 16, 2023 7:09 pm
by wwonderfull
There are some good informations here check and see if it is useful.
https://stackoverflow.com/questions/402 ... h-htaccess

Re: Htaccess help remove .php

Posted: Sat Sep 16, 2023 9:00 pm
by BaconFries
From a previous post by yourself you write you are using ionos? If so it could be that MutliViews is enabled and this could stop/break the .htacess. I am no expert in this but you can try adding the following below to the top of your .htacess file. GoDaddy has a similar issue but you need to add Options +MultiViews to the top/start of the .htacess for the page extension to be hidden so it could be you need to add what I suggest in ionos. If this doesn't help it might be best to contact your host.
Add to top/start of your code

Code: Select all

# Ensure that MutliViews is disabled
Options -MultiViews

Re: Htaccess help remove .php

Posted: Sat Sep 16, 2023 9:39 pm
by Manchester_man
Thank you, I shall try this. You are right, I do use Ionos.
Thanks ever so much