我正在尝试将php代码嵌入到我的godaddy托管站点的html页面中。我知道如何通过编辑我的.htaccess文件来指导我如何在godaddy上这样做。
我的问题是,我想在windows webmatrix2.下在本地开发webmatrix2。
在作为服务器运行iis或iis矩阵的windows服务器下,需要做什么?我的godaddy帐户是托管在linux下的,但我是在windows下使用webmatrix进行开发的。
我发现的解决办法不起作用。
1)根据一个来源,将这些行添加到applicationhost.config文件中
<add name="PHP53_via_FastCGI_html" path="*.html"
verb="GET,HEAD,POST" modules="FastCgiModule"
scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe"
resourceType="Either" />
在iisexpress目录下。他们毁了我当地的整个网站。
2)在the矩阵中,在web.config文件中为站点添加此重写规则。
<system.webServer>
<rewrite>
<rules>
<rule name="REWRITE_TO_PHP">
<match url=".html" />
<conditions logicalGrouping="MatchAll" />
<action type="Rewrite" url=".php" />
</rule>
</rules>
</rewrite>
... more code
3)或在web.config中尝试此方法。
<rewrite>
<rules>
<rule name="REWRITE_TO_PHP">
<match url="*.html" />
<conditions logicalGrouping="MatchAll" />
<action type="Rewrite" url="{"*.Php"} />
</rule>
</rewrite>
4)或在web.config中尝试此方法。
<handlers>
<add name="html via php cgi" path="*.html" verb="*" modules="FastCgiModule"
scriptProcessor="C:\Program Files\Php\php-cgi.exe"
resourceType="Unspecified" />
</handlers>
以上这些对我都不起作用。我知道以上所有的这些都是很多信息。这就是我在冗长的网络搜索中所能找到的全部内容。我不是一个系统程序员的经验。我只需要一些能让我开始在windows上用html编写php代码的东西。关键的突破将是如果我开始看到我的php在关键字颜色中显示,并且有webtrix工作!Intellisense是伟大的!谢谢。
发布于 2013-03-07 22:30:55
我也有同样的问题。
解决方案:使用以下代码在网站根目录中创建web.config文件:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="GeneralRewrite" stopProcessing="true">
<match url="^(.*).html$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="{tolower:{R:1}}.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
发布于 2014-09-08 13:52:49
在你的web.config文件中你应该有
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PHP_via_FastCG1" path="*.htm" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP5.5\php-cgi.exe" resourceType="Either" />
<add name="PHP_via_FastCG2" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP5.5\php-cgi.exe" resourceType="Either" />
</handlers>
</system.webServer>
</configuration>
其中scriptProcessor="C:\PHP5.5\ php -cgi.exe“取决于您的php实际存储在系统上的位置。您可以使用phpinfo()来提示系统的位置。
发布于 2013-03-12 14:38:11
好的,我认为您想要做的只是在apache上工作,而不是使用webmatrix。欲了解更多信息,请阅读:Php tags in .html files don't work in WebMatrix
https://stackoverflow.com/questions/12667677
复制相似问题