Related Podcast Link: Listen to Episode 123!
I love using PHP code and scripts. They can come in handy a lot of different ways in a lot of different places. In most cases people learn that if you want to run PHP scripts or execute PHP code your pages need to be in the .php format. What if all of your pages are already .html, .htm, or dot something else?
You are not left in the dark – I promise.
For an example, lets say Chuck has a large web site that is all done with .html pages. It was setup a long time ago, he didn’t know about any of the new web technologies out there, and he was happy with his simple static site. Now his friend Billy tells him he could add a few more dynamic things if he used some PHP code here and there.
The problem is Chuck doesn’t want to turn all his .html pages to .php pages.
What Chuck needs to do is add a few simple lines to his .htaccess file:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
After that, all of Chuck’s .html pages will be pushed through the server as .php pages. So this way he can keep his .html extension but use PHP. Now I know that isn’t the most technical way of putting things, but it is a way that we can all understand. The important thing is now Chuck can now execute PHP scripts in .html files.








Comments are closed.