Making PHP Read as HTML
In a recent article I wrote, I mentioned a neat way to track when Google visits your Web site.
The only problem is I got dozens of E-mails from people who used the “.html” extension on their pages who wanted to know how they could make it work on the Web site they run. I have good news. With a little work, you can make PHP readable on a HTML-based page.
This is actually more of a work around than a real answer. You should also know that by doing this, you will be pushing all of your Web pages with the “.html” extension through the server’s PHP parser. Simply put, all the Web pages will be pushed through the part of the server that reads PHP code.
This could put somewhat of a strain on the server itself, but I have yet to really see a huge problem reported with it. If you have a dozen or so pages, you probably will not see a problem. However if you have thousands of pages, I would not recommend this.
All you need to do is add a line of code into your .htaccess file:
AddType application/x-httpd-php .php .html
That is it. Now will treat all the code in your pages as PHP before it displays it on the page, making my previous article now possible, even if you have a “.html” extension on your Web site pages.
Mitch Keeler is a guy who likes to help people out in his own charismatic and odd way. Instead of showing somebody how to do something, he much more enjoys having people see the problem and the solution through his own eyes. Mitch has worked as an article and content writer for various Web sites around the globe.
Mitch Keeler is also a former Customer Service Director and Customer Service Manager for a large Web hosting company. Please feel free to contact Mitch or look over his impressive resume of accomplishments.