Ten Ways to Use PHP On Your Website

eLearning Series

by

Customer Paradigm
888.772.0777
303.499.9318

Have you ever wanted to make a site more dynamic, but didn't want to have to change all of the page names? There's an easy way to do this... read more below >>

Ten Ways to Use PHP On Your Website
Tip #4: Using PHP on HTML Pages

How can I use PHP code if my pages end in .HTML?

One of the biggest challenges when upgrading the functionality of a website is changing all of the page names.

For example, if you have a site that has pages that end in .html or .htm, this means that you usually don't have the ability to use some of the time-saving features of php scripting. For example, the navigation can't be placed in a separate file that you can update everything in one area (vs. having to edit each and every page of the site). Or, you couldn't pull off last week's tip... personalizing a site based on geographic location.

Most web developers will tell you that in order to use php, you need to change all of your file names to .php. So the about.html page would change to about.php.

Error 404 - broken links It's painful to rename all of your pages

This is less than ideal for many reasons.

Why? First, you may have lots and lots of links inside your site that would then need to be changed, often one at a time, in order to prevent broken links.

Second, other websites may be linking to one or more pages of your site, and changing the navigation can cause you to lose the value of inbound links, both from a traffic perspective and a search engine popularity perspective.

Third, many search engines may have already indexed your site successfully. If you change all of the page names, a search engine will then have to re-index all of your content, and you risk losing position.

While there are ways to use 301 redirects to make sure that the old page name will automatically forward to the new page name, but for a website with many pages, this can be a long and painful process.

The Work-Around

One way to work around the limitation of php scripting is to essentially tell your server that an HTML page (i.e. a page ending in .html or .htm) should be treated just like a page that ends in .php.

The way to accomplish this is fairly technical, but if you have an Apache-based Web server, you can modify the .htaccess file on the server:

Add this line into the .htaccess file:

AddType application/x-httpd-php .htm .html

The .htaccess file is generally where the error 404 handling is set up for your site:

Edit your .htaccess file to enable html pages to run php scripts

Then, you can add php code into your .html pages, such as:

php include file code

And it should work properly!

Summary:

There is a way to trick your webserver to think an HTML page can run php scripting, allowing you to add interactive features, but not have change all of the names of your pages.

 

I hope you enjoyed this first part of the series. Let me know if you'd like to explore how php can take your website to the next level of interactivity.

Talk to you soon,

Jeff FinkelsteinFounder, Customer Paradigm

Jeff Finkelstein

Founder, Customer Paradigm

Connect Via Facebook >>
Connect Via Linked In >>

We love referrals! Our Referral Promise >>

Customer Paradigm
5353 Manhattan Circle, Suite 103
Boulder, Colorado 80303
Visit our Website
direct 303.499.9318
fax 303.374.6104
toll free 888.772.0777
Web & Print Design · Programming · Email Newsletters · Search Engine Marketing · eCommerce

 

<< back to list of Ten Ways to Use PHP Programming on Your Website

Sign Up to Receive these Strategies in your Inbox:

  • Please fill out the form on this page to sign up.
    The emails usually go out on Friday mornings.

Please have someone contact me regarding these strategies:

First Name :
Last Name :
Phone :
Email :
Comments :
 
  Word Verification:
  Enter the word as it is
shown in the box to the right.

 This step is required to prevent abuse of our services.