PHP Script is not working in .html file

Vasanthjan

Member
Mar 8, 2017
14
0
1
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>
 
Last edited by a moderator:

vacancy

Well-Known Member
Sep 20, 2012
309
89
28
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.
 

Vasanthjan

Member
Mar 8, 2017
14
0
1
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,911
2,234
363
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
Hello,

I'm happy to see you were able to address the issue. Thank you for updating us with the outcome.
 
  • Like
Reactions: Vasanthjan