The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Allow PHP in Htm and HTML pages

Discussion in 'General Discussion' started by cmwh, Aug 11, 2008.

  1. cmwh

    cmwh Member

    Joined:
    Apr 7, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    Running WHM and CP 11.+++

    PHP 5

    I have changed the htaccess files on the web site and on the server but I can not get php to work in a html page.

    I tried with AddType application/x-httpd-php .php .htm .html

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

    I want to add a header. The webpages are built from a template. I am adding a header in an editable region.

    Any suggestions. It is a huge web site and it would take at least a week to switch the whole website to php.

    Thanks
     
  2. UBERHOST

    UBERHOST Well-Known Member

    Joined:
    Jan 13, 2008
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    California, US
    Have you tried enabling this through cPanel?

    Apache Handlers

    Create An Apache Handler

    Handler x-httpd-php

    Extension(s) .html

    Click "Add".
     
  3. cmwh

    cmwh Member

    Joined:
    Apr 7, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    php

    I added the handlers and still no luck.

    <!-- InstanceBeginEditable name="EditRegion4" -->
    <div align="left"><?php include("header.php"); ?></div>
    <!-- InstanceEndEditable --></div>

    This is the page. http://www.unityinchrist.com/john/phptry.html

    the htacess now looks like this for the website
    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName www.unityinchrist.com
    AuthUserFile /home/pbenson/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/pbenson/public_html/_vti_pvt/service.grp
    Redirect temp /gbook.html http://guestbooks.christiansunite.com/sign.cgi?u=pambenson
    AddType application/x-httpd-php .html
    AddHandler x-httpd-php .html
    AddHandler x-httpd-php .htm
     
    #3 cmwh, Aug 11, 2008
    Last edited: Aug 11, 2008
  4. Nazaret

    Nazaret Member

    Joined:
    Jul 15, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    edit your htaccess and use the following

    AddHandler application/x-httpd-php5 .htm
    AddHandler application/x-httpd-php5 .html
     
  5. cmwh

    cmwh Member

    Joined:
    Apr 7, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
  6. Nazaret

    Nazaret Member

    Joined:
    Jul 15, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Please post your current htaccess
     
  7. cmwh

    cmwh Member

    Joined:
    Apr 7, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    current htacess

    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName www.unityinchrist.com
    AuthUserFile /home/pbenson/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/pbenson/public_html/_vti_pvt/service.grp
    Redirect temp /gbook.html http://guestbooks.christiansunite.com/sign.cgi?u=pambenson
    AddType application/x-httpd-php .html
    AddHandler x-httpd-php5 .html
    AddHandler x-httpd-php5 .htm
     
  8. Nazaret

    Nazaret Member

    Joined:
    Jul 15, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    remove AddType application/x-httpd-php .html and try again
     
  9. cmwh

    cmwh Member

    Joined:
    Apr 7, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    No luck it didn't work
     
  10. djbob2

    djbob2 Well-Known Member

    Joined:
    May 14, 2005
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    16
    Open up /usr/local/apache/conf/mime.types (I am using Apache 2.2 - perhaps the configuration is in httpd.conf for earlier versions) and find out what MIME type corresponds to PHP. Then add the following to your .htaccess file:

    AddHandler mime-type-goes-here .html
     
  11. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    16
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    Go into your cpanel for the site and then go to apache handlers

    add server-parsed .htm and server-parsed .html

    then add this to your .htaccess file

    AddHandler application/x-httpd-php .htm
    AddHandler application/x-httpd-php .html
    AddType application/x-httpd-php .htm
    AddType application/x-httpd-php .html
     
  12. cmwh

    cmwh Member

    Joined:
    Apr 7, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    Tried everything

    I have tried all the suggestions and nothing works.

    my htacess now looks like this;

    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName www.unityinchrist.com
    AuthUserFile /home/pbenson/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/pbenson/public_html/_vti_pvt/service.grp
    Redirect temp /gbook.html http://guestbooks.christiansunite.com/sign.cgi?u=pambenson
    AddHandler x-httpd-php5 .html
    AddHandler x-httpd-php5 .htm
    AddHandler application/x-httpd-php .htm
    AddHandler application/x-httpd-php .html
    AddType application/x-httpd-php .htm
    AddType application/x-httpd-php .html
     
  13. Tigerlady

    Tigerlady Registered

    Joined:
    Oct 28, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Chicago
    I see this never got completely answered because I am having the same issue. We just took on a new client and from their old company they had PHP in html pages. I have tried all the suggestions posted here and they do not work.

    here is the contents of my .httaccess file.

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

    When i look at the file through file manager index.html type is listed as application/x-httpd-php

    however, when browsing the file Firefox tries to download the file and IE shows the php code at the top.

    if i rename the file to php it works fine but we do not want to go through the entire site and remap everything. Does anyone have another suggestion?

    thank you.
     
  14. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    16
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    Do this like I posted above

    Go into your cpanel for the site and then go to apache handlers

    add server-parsed .htm and server-parsed .html
     
  15. Tigerlady

    Tigerlady Registered

    Joined:
    Oct 28, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Chicago
    as i said i tried all the suggestions above and still can't get it to work.
     
  16. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,382
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Is there a particular reason why you can't use .php file extensions?
     
  17. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    16
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    I cant understand why its not working for you.

    I have several sites that are doing it the same way you are trying.

    we set apache handler to server-parsed for htm and html and add this to the htaccess file and it works perfect

    AddHandler application/x-httpd-php .htm
    AddHandler application/x-httpd-php .html
    AddType application/x-httpd-php .htm
    AddType application/x-httpd-php .html
     
  18. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    16
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    Make sure your httpd.conf has this in it

    <Directory "/">
    Options All
    AllowOverride All
    </Directory>

    It is possible your apache conf file is not allowing the .htaccess to override the main conf file
     
  19. Kent Brockman

    Kent Brockman Well-Known Member

    Joined:
    Jan 20, 2008
    Messages:
    1,130
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Buenos Aires, Argentina
    cPanel Access Level:
    Root Administrator
    Twitter:
    AFAIK, files with html extension SHOULDN'T BE PARSED by php, by any means. If you need to camouflage that php files as html ones, I wonder if you may use a mod_rewrite rule to get it done.
     
  20. wa4fat

    wa4fat Well-Known Member

    Joined:
    Dec 30, 2001
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    8
    Frontpage a possible culprit

    I'm guessing there may be an issue with Frontpage and .htaccess. Google is loaded with examples of Microsoft frontpage extensions wreaking havoc with .htaccess files, including this comment on a major hosting firm's FAQ:

    "The .htaccess files generated by Microsoft FrontPage are not compatible with the basic .htaccess files normally created for Apache servers. Installing FrontPage Extensions allows your portion of the server space to be compatible with Microsoft .htaccess files and not Apache .htaccess files. The server will not operate properly if you have both Microsoft and Apache .htaccess files installed for the same domain name."

    For what it's worth --- your mileage may vary.

    Good luck // Bill
     
Loading...

Share This Page