The Voice of the Web Hosting World
The Web Hosting Show is the number one web hosting and development podcast. Never miss an episode! Subscribe today to our RSS feed for free, or subscribe via iTunes.

Enter your e-mail address to get daily tips delivered to your inbox:

How to Make HTML Pages Recognize PHP

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.

| More

Related Posts & Podcasts

jsp
What is JSP?
When shopping for a web host, or perhaps just looking to upgrade your existing hosting setup, you see a lot of checkmarks.  One of those green checkmarks you see might be for JSP.   So what is JSP?  JSP is

Classic HTML vs CSS – Who Wins?
When it comes to Web design, there is one battle that seems to have gone on for ages. Which is better, using tables and classic code in your HTML code to design things or use cascading style sheets (otherwise

error-pages
5 Common HTTP Errors (to watch out for)
It is no secret that bad things sometimes happen to good web sites.  When this happens on your web hosting account, it is often shown as a HTTP error.  Each problem that could happen with a web site, has an

blog comments powered by Disqus

Mitch Keeler © 2009 - Sitemap | Privacy Policy
Dedicated Server Hosting provided by Layered Tech

Go to Top of Page