是否可以在 IIS7 的 html 中包含 php?
在 Apache 中似乎可以这样做,
It seems to be possible to do so in Apache,
在 HTML 中包含 php 脚本
但是我可以让我的 IIS 7 为 php 解析 html 文件吗?目前,我的 html 文件允许包含 asp 文件,如果我可以使用 php 文件来实现,那就太好了.
But can I make my IIS 7 parse html files for php? Currently my html files allow asp includes like it would be splendid if I could just do that with a php file.
我的服务器运行你所期望的 .php 文件.
My server runs .php files as you would expect.
我尝试的是在 IIS 中添加一个处理程序映射,其值与使用我的 IIS/PHP 安装创建的 *.php 映射相同,仅切换为 *.html
What I've tried is adding a Handler Mapping in IIS with the same values as the *.php mapping that was created with my IIS/PHP install, only switched for *.html
这不起作用,然后我在 web.config 文件中添加了一个处理程序
This didn't work, then I added a handler in my web.config file
<add name="PHP_via_FastCGI" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:Program Files (x86)PHPv5.3php-cgi.exe" resourceType="Either" requireAccess="Script" />
就像那样,这并没有改变任何东西.
like that, and that didn't change anything.
当我运行一个包含 php 代码的 html 文件时没有错误,只是代码根本没有运行.
There are no errors when I run an html file with php code in it, the code just simply does not run.
假设我不能简单地将 index.html 更改为 index.php.
Let's assume that I cannot just simply change my index.html to an index.php.
推荐答案
对于从 apache 迁移到使用 .php
和 混合的 IIS 的站点,我必须让它工作.html
用于它的脚本.我的 web.config 中有这个(裁剪无用的东西):
I had to get this working for a site migrated from apache to IIS that used a mixture of .php
and .html
for it's scripts. I have this (cropped useless stuff) in my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PHP53_via_FastCGI_HTML" path="*.html" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:Program Files (x86)PHPv5.3php-cgi.exe" resourceType="File" requireAccess="Script" />
</handlers>
</system.webServer>
</configuration>
你把它放在正确的部分了吗?我讨厌我看到的大多数 web.config 示例实际上并没有告诉你想要它们应该在 </rant>
Have you got it in the right section? I hate that most web.config examples I see don't actually tell you want section they should be in </rant>
相关文章