How to remove .php .html via .htaccess?

by muriel.schmidt , in category: Third Party Scripts , 4 months ago

How to remove .php .html via .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jerad , 4 months ago

@muriel.schmidt 

To remove the file extensions .php or .html using .htaccess, you can use the following code in your .htaccess file:


For removing .php extension:

1
2
3
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]


For removing .html extension:

1
2
3
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [NC,L]


Make sure to save the changes and upload the .htaccess file to the root directory of your website. This code will remove the specified file extensions from URLs in your website.