newbie
newbie

Reputation: 3

Rewrite html file for php with .htaccess

I need help with converting html with php .

So far My code is

RewriteEngine on 
RewriteRule ([a-z]+).html /$1.php 

This is working fine. but some real html pages have php scripts ,that doesnt run. how to fix this? thanks

Upvotes: 0

Views: 91

Answers (2)

vitally
vitally

Reputation: 377

Try this:

RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]

Upvotes: 2

Amit Verma
Amit Verma

Reputation: 41219

You can use AddHandler directive to change the mime type of a file

Add the following line to your htaccess file

AddHandler application/x-httpd-php .html

Now all your html files will work as php.

Upvotes: 2

Related Questions