How to remove the .php extension in .htaccess file?

by edmond_brakus , in category: Third Party Scripts , 3 months ago

How to remove the .php extension in .htaccess file?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by lindsey.homenick , 3 months ago

@edmond_brakus 

To remove the .php extension from URLs using an .htaccess file, you can use the following code:

1
2
3
4
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php


Simply add this code to your .htaccess file in the root directory of your website. This code will remove the .php extension from URLs and allow you to access PHP files without including the extension in the URL.