The scenario is I have a blog powered by Movabletype. All html files. Later I need it to be running like a php file. Then I can add php codes inside without changing extension name from html to php.
I’d like to keep the URL. The blog is about five years old.
OK.
Two years ago, I add the following into .htaccess file, which is from Let php engine handle html as php.
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

It works very well until last week.
I got the error like ask me save the file or not. It is not return the correct php or html file.


I did a lot of research. No answer. I have to submit the ticket to host provider. He gave me the answer and solution.
Your.htaccess file is telling our server to send your .html and .htm
files through the PHP interpreter loaded into apache as a module
(mod_php). We haven’t supported that setup for about 4 or 5 years now,
but we’ve left it running for the convenience of people still relying on
it to work. PHP version 4 is now so out of date that leaving it running
makes our servers fail security scans though, so we’ve been forced to
disable it.
You’ll want to comment out any lines like this:
AddType application/x-httpd-php .html .htm
And change it to something like this…
AddType php5-cgi htm html
This will make your scripts run through our PHP5 binary instead. Let me
know if you have any other questions!
Thanks!
Jeff H

Good. It really helped me out.

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

2 Replies to “Run php from HTML file

  1. Thanks for sharing this! I spent (wasted) quite a bit of time this morning trying to get my site working. Just a simple matter of changing a line in the .htaccess, works perfect!

Leave a Reply

Your email address will not be published. Required fields are marked *