1

我正在尝试在我的 godaddy linux 托管网站上的 html 页面中嵌入 php 代码。我知道如何通过编辑我的 .htaccess 文件来指导我如何在 Godaddy 上执行此操作。

我的问题是我想在windows webmatrix2下本地开发。

在运行 iis 或 webmatrix 作为服务器的 windows 服务器下需要做什么?我的 godaddy 帐户托管在 linux 下,但我使用 webmatrix 在 windows 下开发。

我发现不起作用的解决方案。

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) 在 Webmatrix 中,在站点的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 工作!智能感知很棒! 谢谢你。

4

3 回答 3

0

在您的 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() 来提示您的系统可能在哪里。

于 2014-09-08T21:52:49.997 回答
0

我有同样的问题。

解决方法:在你的网站根目录下创建一个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>
于 2013-03-08T06:30:55.880 回答
-1

好的,我认为您想要做的仅适用于 apache 而不是 webmatrix。有关更多信息,请阅读:.html 文件中的 Php 标记在 WebMatrix 中不起作用

于 2013-03-12T22:38:11.140 回答