Html embedded php code not executed when hosted on iis
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<TITLE></TITLE>
</HEAD>
<BODY>
<?php echo '<p>Hello World</p>'; ?>
</BODY>
</HTML>
When I run the above code in a browser, firefox does it like this:
Hello World
'; ?>
I am doing my coding on Windows XP / IIS 5.1. I configured PHP correctly because I have no problem running .php files. The problem, it seems to me, is that IIS cannot display PHP code embedded inside html. Does anyone know how to fix this problem, or should I switch to Apache?
edit: file extension .html
a source to share
The same problem using Windows 7 IIS and php can be solved by going to Start-> Control_panel-> Administrative_Tools-> Internet_Information_Services_ (IIS) _Manager. Then you need to select the connection that has the problem, then double click on "Handler Mappings"
on the right side of the table you can see the "Actions" panel, click "Add module mapping", in the "Request path" field you should write "* .html" (without quotes), in the "Module" section, select "FastCgiModule", in the "Executable file" find the path to the php-cgi.exe file, in the "Name" section write let say "html" (wihtout quotes),
then click the "Request Limits" button, check the "Invoke" handler only if the request is mapped to "and select" File or folder "click" OK "click" OK "again click" Yes "
now your iis server should understand php script in * .html documents.
a source to share
You need to tell IIS to run your files .html
through the PHP interpreter and not serve them directly.
I'm not sure how it's done ... little google search:
NB / Caveat emptor What follows from the Microsoft support site and the answer to the question about setting up IIS with Perl - I believe it should work in PHP too, or at least run you on the right path, but I haven't tested it as I don't have IIS.
Click Start, select Programs, click Administrative Tools, and then click Internet Information Services. Right-click the website you want to enable PHP, and then click Properties. Click the Home Directory tab. Click Settings ". Click Add. Enter the following command for the executable file: Full path to php.exe \ php.exe% s% s Note." % s% s "is case sensitive (for example,"% S% S "does not work). For Extension, enter .html.
Note. Make sure all verbs option is selected for full functionality. Also, make sure the Script Engine checkbox is selected. Click OK to return to ISM. Using scripts, the default directory with IIS, the URL is the following: http: // Server Name / scripts / HelloWorld.html
a source to share