How to run PHP from HTML page?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • loyalrogue
    Member
    • Apr 2004
    • 44

    #1

    How to run PHP from HTML page?

    Hi All,

    OZ posted a thread in the General section of FAQ's regarding this subject: http://forums.dathorn.com/showthread.php?t=251

    I have tried adding the line of code he gave to my .htaccess file thru cpanel using the file manager.
    "AddType application/x-httpd-php .php .htm .html .shtml"

    It saves fine but when I try to access my site afterwards I get an "Internal Server Error".

    Does anyone have a suggestion about what could be the problem?
    Oz? You there?

    Thanks in advance for any insights.
  • loyalrogue
    Member
    • Apr 2004
    • 44

    #2
    I finally got it to work.
    Apparently you can't just stick that code anywhere in the htaccess file.
    I had to paste it into different lines untill I got it to work.

    **Edit

    The actual line to add to the htaccess file is:
    Code:
    AddHandler application/x-httpd-php .php .html .htm
    I originally added it to the end of the file with no success.
    It worked fine after I moved it to the "head" of the file as in the example below.
    Code:
    # -FrontPage-
    
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    AddHandler application/x-httpd-php .php .html .htm
    
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName [url]www.mydomain.com[/url]
    AuthUserFile /home/myusername/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/myusername/public_html/_vti_pvt/service.grp
    Last edited by loyalrogue; 09-20-2004, 05:58 PM. Reason: Moved response from end of thread.

    Comment

    • -Oz-
      Senior Member
      • Mar 2004
      • 545

      #3
      If you want to post the exact .htaccess file in a [.CODE] box that'd probably help quite a few people
      Dan Blomberg

      Comment

      • Jim
        Member
        • Mar 2004
        • 44

        #4
        I'm having the same problem and the only line in .htaccess is

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

        I'm either getting a 500 error, or the html file is being downloaded as a file instead of displayed.

        I've read that any file that you want to be processed by PHP must end in the .php extension after phpsuexec. Is this correct?

        Comment

        • bjacobs
          Junior Member
          • Mar 2004
          • 28

          #5
          In my public_html folder, in the .htaccess file, this is what I have added to make htm, html pages to be able to run php scripts:

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

          And it has worked fine since I put it in.

          Comment

          • -Oz-
            Senior Member
            • Mar 2004
            • 545

            #6
            You may want to manually make the file rather than doing it through cpanel and make sure its in the public_html dir and not anywhere else (such as in folders for subdomains).
            Dan Blomberg

            Comment

            • AndrewT
              Administrator
              • Mar 2004
              • 3655

              #7
              Originally posted by bjacobs
              In my public_html folder, in the .htaccess file, this is what I have added to make htm, html pages to be able to run php scripts:

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

              And it has worked fine since I put it in.
              What server are you on? That should not be working, it should create 500 errors.

              Comment

              • Jim
                Member
                • Mar 2004
                • 44

                #8
                Originally posted by AndrewT
                What server are you on? That should not be working, it should create 500 errors.
                So am I correct that this can't be done with phpsuexec installed?

                Comment

                • AndrewT
                  Administrator
                  • Mar 2004
                  • 3655

                  #9
                  Originally posted by Jim
                  So am I correct that this can't be done with phpsuexec installed?
                  That is correct. You *might* be able to do something with mod_rewrite to make it workable, but I doubt it.

                  Comment

                  • bjacobs
                    Junior Member
                    • Mar 2004
                    • 28

                    #10
                    Originally posted by AndrewT
                    What server are you on? That should not be working, it should create 500 errors.
                    I'm on 14.

                    Comment

                    • AndrewT
                      Administrator
                      • Mar 2004
                      • 3655

                      #11
                      Well, I now stand corrected. Using the AddHandler command should work just fine, it's the AddType command that will result in a 500 error.

                      Code:
                      AddHandler application/x-httpd-php .php .shtml .html .htm

                      Comment

                      • Jim
                        Member
                        • Mar 2004
                        • 44

                        #12
                        Thanks for that bjacobs & Andrew. I just tried it and it works fine. Sure beats renaming all my files to .php

                        Comment

                        • bjacobs
                          Junior Member
                          • Mar 2004
                          • 28

                          #13
                          Yes, I want to thank Andrew for his very quick response!

                          Comment

                          • loyalrogue
                            Member
                            • Apr 2004
                            • 44

                            #14
                            Originally posted by -Oz-
                            If you want to post the exact .htaccess file in a [.CODE] box that'd probably help quite a few people
                            Ooops. I guess I don't have email notification turned on.
                            I didn't realize this thread had replies.
                            Oh well, better late than never, right?
                            The actual line to add to the htaccess file is:
                            Code:
                            AddHandler application/x-httpd-php .php .html .htm
                            I originally added it to the end of the file with no success.
                            It worked fine after I moved it to the "head" of the file as in the example below.
                            Code:
                            # -FrontPage-
                            
                            IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
                            AddHandler application/x-httpd-php .php .html .htm
                            
                            <Limit GET POST>
                            order deny,allow
                            deny from all
                            allow from all
                            </Limit>
                            <Limit PUT DELETE>
                            order deny,allow
                            deny from all
                            </Limit>
                            AuthName [url]www.mydomain.com[/url]
                            AuthUserFile /home/myusername/public_html/_vti_pvt/service.pwd
                            AuthGroupFile /home/myusername/public_html/_vti_pvt/service.grp
                            Thank you to all for the help.
                            Dathorn rocks!

                            Comment

                            • xdhirax
                              Junior Member
                              • Feb 2006
                              • 3

                              #15
                              Code:
                              Originally Posted by Jim
                              So am I correct that this can't be done with phpsuexec installed?
                              Code:
                              That is correct. You *might* be able to do something with mod_rewrite to make it workable, but I doubt it.
                              I have phpsuexec on my server (another host) and that line doesnt work at all.
                              Is there a suggestion that might work with phpsuexec installed? Such as the mod rewrite that was suggested perhaps?

                              Comment

                              Working...