View Full Version : PHP and HTML

01-25-2005, 09:01 PM
Forgive me, I have done a search and all the info to do this is out there... I'm just having trouble putting it all together.

Can someone explain to me EXACTLY what needs to be done to parse PHP in HTML files? I know I need to add things to the .htaccess file and take things out of the apache config file (I think), but I'm having a bit of trouble figuring out what needs to be added and where are these files located.

I really have tried to figure this out, but I'm at an impass. Thanks in advance.

01-26-2005, 02:21 AM
If the file that you want parsed ends in '.php' then you don't need to do anything, Apache passes that off to the PHP system for processing.
If the filename ends in '.html' then you will need to tell Apache that all files need to be handed off to the PHP engine. If this is what you want to do, then I have to ask: Why?

02-06-2006, 02:45 AM
Its been a year, so I'll reply.

Lets say you have a well established site done in a really crappy manner. Frames and all. Its horrific.

BUT Google really likes you and for what you are doing it ranks you on the front page when it counts.

So you've got all these pages like whatever.htm that you want to rewrite in PHP. But if you change the URL to whatever.php... poof... that google rank goes baba... and yes you can do a redirect with .htaccess but you will still lose that "rank"... if I understand things correctly. (Which I may not...)

I hope this is clear, and that it doesn't take a year for someone to respond.


02-06-2006, 07:55 AM
If you do a redirect either via .htaccess or by inserting it in the actual .htm file I don't quite understand why you would loose your ranking. When google tries to access the old page it should be redirected to the new page and thus would pick up on the content and make adjustments to thier database.

WestHost - SHales
08-28-2006, 09:30 AM
You can parse a .htm/.html file as php by performing the following:

Open your Apache configuration file ( /etc/httpd/conf/httpd.conf ) after installing PHP and edit it as follows (this applies to Mod PHP 5 - if Mod PHP 4 has been installed, replace mod_php5.c below with mod_php4.c) - note the .html .htm added to the end of the second line:

<IfModule mod_php5.c>
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .html .htm
AddType application/x-httpd-php-source .phps

The last step is to remove the .htm and .html from the following line in the
httpd.conf file:

AddHandler server-parsed .shtml .htm .html

thus after the edit, it appears as:
AddHandler server-parsed .shtml

The .htm and .html file extensions are already set up to be parsed for SSI. Leaving them causes the SSI to conflict with parsing them as PHP:

Restart apache (or the VPS) to process the changes.