How to use htaccess

Hello All,

I am trying to use htaccess for hiding php extension by html extension.

I have used this rule in htaccess file->

RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]

When I will click on php file, it should come as htm file in browser.
Now when I click on php file,it is coming as php file itself. I have to explicitly write on addressbar of browser as htm file,then content of php file is displayed.

I also used this rule in htaccess->
AddType application/x-httpd-php .htm .
But no change in behavior of execution of file.

Help is needed.

Thanks & regards,
Sheetal Mhalsekar

You need to update the links in your website that point to .php files to point to .htm files. :slight_smile:
And the AddType is not need (and not recommended).
Also, you don’t need [nc], but should add the last flag, [L]


RewriteEngine on
RewriteRule ^(.*)\\.htm$ $1.php [L]