Htaccess help remove .php

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
Manchester_man
 
 
Posts: 26
Joined: Mon Mar 23, 2015 1:41 am

Htaccess help remove .php

Post 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
wwonderfull
 
 
Posts: 1327
Joined: Fri Aug 21, 2020 8:27 am
Contact:

Re: Htaccess help remove .php

Post by wwonderfull »

There are some good informations here check and see if it is useful.
https://stackoverflow.com/questions/402 ... h-htaccess
User avatar
BaconFries
 
 
Posts: 5541
Joined: Thu Aug 16, 2007 7:32 pm

Re: Htaccess help remove .php

Post 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
Manchester_man
 
 
Posts: 26
Joined: Mon Mar 23, 2015 1:41 am

Re: Htaccess help remove .php

Post by Manchester_man »

Thank you, I shall try this. You are right, I do use Ionos.
Thanks ever so much
Post Reply