How to rewrite .php to .html using .htaccess rules?

I want to convert the .php extension to the .html extension using .htaccess rules

I can do this, and if so, how?

+6
.htaccess mod-rewrite
source share
2 answers
 RewriteEngine on RewriteRule ^(.*)\.html$ $1.php [nc] 

Uses mod_rewrite. $ 1 points to the first part of the regular expression, and [nc] means case insensitive.

You can take a look at this article: http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html

EDIT: Deleted row. You don't need what I think. Also commented on what I did.

+10
source share

Maybe try

 RewriteCond %{REQUEST_FILENAME} =-f RewriteRule ^(.*)\.php$ $1.html [NC,L] RewriteRule ^(.*)\.html$ $1.php [NC,L] 
+3
source share

All Articles