Results 1 to 7 of 7
  1. #1
    Full Member
    Join Date
    January 18th, 2005
    Location
    UK
    Posts
    273
    Runing PHP code in a htm page
    I used to be able to run php code in .htm/.html pages by having the following in my .htaccess file

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

    however since my host updated to Apache 2.0.5 / php 5.2.1
    this no longer seems to work.

    I tried the host support team but they just suggested changing the
    AddType application/x-httpd-php
    line to be
    AddHandler application/x-httpd-php .html
    but that does not help.

    I then started doing some web searching but to no avail as the nature of the issue menas that the right keywords are pretty generic.

    Normally I am pretty good at sorting myself out after a bit of time in Google but on this I seem to be struggling.

    The other thing I perhaps should mention is that I have multiple domains on the one account so I suspect I should be doing this in the Apache http conf file in the virtual host statements, although I still can't get php in htm pages to work on the primary main domain anyway.

    Any help/advice very gratefully received.

    Les

  2. #2
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    When my host went to php 5.2.1 - I changed the lines to this and it started working again.

    Code:
    AddHandler application/x-httpd-php5 .htm
    AddHandler application/x-httpd-php5 .html
    Notice - I added a 5 to the php. php5.

    The line - RemoveHandler .html .htm - is not even in my .htaccess file. Just the two lines you see in the above code box.
    Last edited by BurgerBoy; July 9th, 2008 at 09:14 PM.

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  3. #3
    Full Member
    Join Date
    January 18th, 2005
    Location
    UK
    Posts
    273
    Hi BurgerBoy

    Your suggestion did not do it for me, but it did spark off a few more things to search for, and got me going with the following addhandler code that I found.

    AddHandler php5-script .htm
    AddHandler php5-script .html

    So many thanks for the suggestion that put me on the right track.

    Haven't been doing too much affiliate work for various reasons, but I am glad to see that as always ABW has the answers directly or indirectly

    Les
    Last edited by websmith; July 10th, 2008 at 08:17 AM.

  4. #4
    Lite On The Do, Heavy On The Nuts Donuts's Avatar
    Join Date
    January 18th, 2005
    Location
    Winter Park, FL
    Posts
    6,930
    Parsing php is one prereq I have for my hosting company, using mod-rewrite is another.

    Here's a good place to test those conditions out:
    http://mydatafeedscripts.com/phpparse/

    I believe these test files, and this page I'm linking to, come from ABW member Oscar. I got it from AMWSO years ago.

  5. #5
    Member
    Join Date
    December 3rd, 2007
    Posts
    177
    Here is the code my host gave me to put in my .htaccess file to run php on html pages:

    AddHandler php-cgi .html .htm

  6. #6
    Full Member
    Join Date
    January 18th, 2005
    Location
    UK
    Posts
    273
    Seems this is one issue where one has to try all the suggestions until one finds the right one for a given host, which in my case is currently westhost, as by and large their support has been pretty good when I have needed it.

    BTW Donuts: the linksky link does not work for me.

    Les

  7. #7
    Member
    Join Date
    December 3rd, 2007
    Posts
    177
    Quote Originally Posted by websmith
    Seems this is one issue where one has to try all the suggestions until one finds the right one for a given host, which in my case is currently westhost, as by and large their support has been pretty good when I have needed it.

    BTW Donuts: the linksky link does not work for me.

    Les
    I tried for days to find the right code, but nothing worked, so I finally sent an email to my host and they sent me the correct code to use.

    Good luck! I hope you find what you need.

  8. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Using PHP (or JS) on .htm or .html pages
    By webworker in forum PopShops
    Replies: 42
    Last Post: September 18th, 2011, 12:09 PM
  2. Php Page / Form Processing / Mysql Insert / No Page Refresh
    By Uncle Rico in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: January 4th, 2009, 11:55 AM
  3. GoldenCAN PHP code & Page Title
    By Trying to Win in forum GoldenCAN
    Replies: 5
    Last Post: September 1st, 2008, 06:21 AM
  4. How do I insert a PHP script into a .htm file
    By dak142 in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: April 2nd, 2004, 06:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •