Removing file extensions from displaying in browser via htaccess

Avatar
  • Answered
I was created .htaccess file with added code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

But it won't work at all. Did i miss something Please help!.
Avatar
Arn
Hello LongNg,

Sorry to hear that you're having problems with the .htaccess file. If you are using .htaccess re-writes, you need to be sure that they are occurring BEFORE any possible re-directs or other things that may affect the rule in the .htaccess file. This means that these rules should be occurring FIRST.

I was not able to verify your site based on your Support Center login, so I'm not able to see if something else was going on in your .htaccess file that may have been affecting these rules. Additionally, these rules are for .PHP and .HTML files. So, if you have any other file extension types, you would need to add another rule in order to remove that extension type.

I hope this helps to clarify the issue for you! Please let us know if you continue to have any further questions or comments.

Regards,
Arnel C.