Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replacing .php ext with .html through .htaccess

Tags:

People also ask

What is the use of htaccess file in PHP?

htaccess file is created in order to enable extra features for that subdirectory. You can use the . htaccess file to modify various configurations and thus make changes to your website. These changes include authorization, error handling, redirects for specific URLs, user permissions, etc.


Greetings!

I'm trying to replace .php extensions with .html

So far I got:

RewriteRule ^(.*)\.html $1.php

... it works nicely when url like /site/page.html is entered (and page.html does not physically exist but page.php does).

However what I'd like to have is when /site/page.php is entered the viewer sees only /site/page.html in the browser location.

Is that doable or do I have to set up explicit redirects for each page? :-(

Thanks in advance.

ps: dev environment I'm using is XAMPP on os x if it makes any difference