cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Running php in html files

Does anyone know how to call a php script from within an HTML file?

 

Do I need to do anything on the server side to get it to work?  I added a file named ".htaccess" to the directory my script is located in that contains the following line:

 

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

 

However, when I try to access the HTML page, it just automatically downloads the HTML file to my desktop for some odd reason.

 

Help please!

 

Thank you!

4 REPLIES 4

Re: Running php in html files

Rename the html file to a php file in order to use php code.
New

Re: Running php in html files

How to allow PHP inside HTML by some settings in web.config  (without using .PHP extension)

I have seen tried the following but it causes the whole web site to fail.

 

handlers accessPolicy="Read, Script">
         <add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe|-d open_basedir=C:\Websites\Website1" resourceType="Unspecified" requireAccess="Script" />
     </handlers>

New

Re: Running php in html files

Were you able to find a fix for this?  I have the same issue running htm files as php. 

 

My old site used AddType/Addhandlers method, but I cant seem to make that work with GoDaddy.

 

Thanks,

New

Re: Running php in html files

1. Add following 3 lines to your .htaccess file in public_html folder

 

Options +ExecCGI

AddHandler fcgid-script .html

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html

 

2. Inside html files php code goes between <?php   ?> tags, for example:

 

<?php echo 'Hello World'; ?>