Skip to content
Advertisement

Remove the .php extension on all pages (NGINX)

Having tried all the solutions on Stack, I was not able to remove the .php extension.

I managed to make the URLs accessible: www.mydomain.com/login but the user can always change the URL to www.mydomain.com/login.php and I’d like to avoid that.

Here is a part of my config :

JavaScript

Advertisement

Answer

This might be what you’re looking for

JavaScript

For .html extensions you just have to add this

JavaScript

If you want to add a trailing slash at the end you can ignore the code above and insert the code below.

JavaScript

If you’re using GoDaddy you need to enable MultiViews at the top of your .htaccess file

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement