Back to top
Copyright 2005 - 2024 - AlfredFox.com - Freelance Website Design

Using PHP Code In Your HTML Files

Posted on: May 14th, 2007 by afoxsiteadmin

I have this habit of not using .php files if at all possible. It’s nothing personal, I simply prefer .html. Whether its more SEO friendly or not is left up to personal opinion and I simply don’t have an answer that will agree with the vox populi (as there are very strong opinions on each side). However I do know this, there are a plethora of posts, blogs, and websites touching on this subject. So I figured I’d not only put in my two cents, but also show you how to do this.

So here’s the tutorial to add PHP functionality to your HTML pages. (Running PHP code in .html files). To do this you need to be able to modify and use a .htaccess file. If you don’t have one and are using an Apache server simply create one in your root web directory. You can speak with your hosting provider for more information on this.

Add this line to your .htaccess file.

AddType application/x-httpd-php .html

That’s it. Now you can run php code in your .html files. Pretty simple.

So my two cents, basically, I guess I don’t have anything to add except I prefer .html files to .php as I’ve stated. There’s nothing wrong with .php files, but a lot of clients I’ve worked with in the past have specifically requested I not use .php. It can go either way though, .php is easily picked up by search engines just as .html. To each his own in this case.



Comments are closed.