01.30.06

php using html extension

Posted in SEO, Tutorials, Misc at 3:14 pm

php using html extension

I know a lot of my readers may already know this but I get asked this question enough that I thought I would get it down in print so I can just send people to it.

I often get the question “How do I use php without changing my url’s?” or “How do I just make one header and footer file to include in each page so I only have to change them once when a change is needed?”.

Some people want to start using some server side programming but don’t want to lose the pages they already have indexed and ranking in the search engine. Some just like to have pages that look like page.html instead of page.php. Some people think they have to change their extensions to .shtml to use includes.

All you have to do is add one line to your .htaccss file. You won’t have one of those if you are running IIS. I’m not sure how to do this on IIS. If you don’t have a .htaccess file then you can just create one. First on your computer create a text file called htaccess without any extension. Put:

AddType application/x-httpd-php .html

in that file.

What this does is tell the server to treat files with the .html extensions as if they had the .php extension. Now you can use php includes ( ). One downside to doing this is that all files will be ran through the php parser. This should not be a big deal since you are putting php in all your pages anyhow for the header and footer.

php using html extension

1 Comment »

  1. beauty said,

    01.25.08 at 10:57 am

    I think it looks a lot cleaner to come up with a nice mod rewrite system that completely removes file extensions and interprets the query string. looks a lot neater.

RSS feed for comments on this post · TrackBack URL

Leave a Comment

Friday 25th of July 2008 06:12:45 AM
expert search engine optimization | www.pack.google.com