Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

PHP Script is not working in .html file

Discussion in 'General Discussion' started by Vasanthjan, Mar 8, 2017.

  1. Vasanthjan

    Vasanthjan Member

    Joined:
    Mar 8, 2017
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    I have placed my sample code below here

    File Name: index1.html

    Code:
    <html>
        <head>
            <title> PHP inside HTML </title>
        </head>
        <body>
            <h1>
                [B]<?php
                           echo "PHP Output";
                ?>[/B]
            </h1>
            <h1>
                [B]<p>
                    HTML Output
                </p>[/B]
            </h1>
        </body>
    </html>
    
    Output Expected

    PHP Output
    HTML Output

    But it showing only HTML output.

    I have tried with various .htaccess codes from different source. None of them is worked for me. I have pasted below the .htaccess codes below for reference. Help me out any to resolve this issue.

    Code:
    [B].htaccess code
    [/B]
    AddHandler application/x-httpd-php56 .shtml .html .htm
    AddHandler server-parsed .shtml .shtm .htm .html
    AddHandler x-httpd-php .html .htm
    AddHandler application/x-httpd-php5 .html .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
    
    2nd Set of Codes Not Working.
    Code:
    AddHandler x-httpd-php5 .html
    AddHandler x-httpd-php5 .htm
    AddHandler application/x-httpd-php .htm
    AddHandler application/x-httpd-php .html
    
    If the MIME types in cPanel. while browser the web page it downloads the page instead of viewing the content.
    AddType application/x-httpd-php .htm
    AddType application/x-httpd-php .html
    
    [I][U]Return Internal Server Error[/U][/I]
    Options +ExecCGI
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html
    AddHandler x-httpd-php5-cgi .html
    
    AddHandler fcgid-script .html
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html
    
    <Directory "<path_to_your_html_dir(in my case: /var/www/html)>">
        AllowOverride All
    </Directory>
    
     
    #1 Vasanthjan, Mar 8, 2017
    Last edited by a moderator: Mar 8, 2017
  2. vacancy

    vacancy Well-Known Member

    Joined:
    Sep 20, 2012
    Messages:
    140
    Likes Received:
    14
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    What are you using handler codes for?

    If you use the default php version, you should not use handler codes in htaccess in inherit mode. If you choose php version, cpanel automatically adds handler codes to htaccess file. The different handler codes you add will create conflicts.

    It can also help with apache error_log records.
     
  3. Vasanthjan

    Vasanthjan Member

    Joined:
    Mar 8, 2017
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Thank you Vacancy, for replying on this.

    I'm using PHP Version 5.6 and my server is powered by CloudLinux also.

    But it is not showing any error logs for me.

    I have tried with this set of codes in the below code it is working fine for me thanks a lot friend.

    AddHandler application/x-httpd-ea-php56 .htm .html .shtml
    AddType application/x-httpd-php5 .php
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm happy to see you were able to address the issue. Thank you for updating us with the outcome.
     
    Vasanthjan likes this.
  5. Donna McMaster

    Donna McMaster Registered

    Joined:
    Jun 27, 2015
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Corvallis Oregon USA
    cPanel Access Level:
    Root Administrator
    FYI, the 2-line solution that Vasanthjan posted didn't work for me, but it pointed me in the right direction. This did work:

    AddType application/x-httpd-ea-php56 .html
     
    cPanelMichael likes this.
Loading...

Share This Page