0

我的 Windows 服务器上的某个目录中有一个特定的 PHP 文件,需要您添加 index.php 才能查看它。

以下作品: http ://example.org/placestorun/index

但以下不起作用: http ://example.org/placestorun/

我使用文件夹的 web.config 文件中的以下代码将 web.config 文件添加到 places to run 目录,使其在没有 index.php 的情况下工作:

<configuration>
   <system.webServer>
    <defaultDocument>
        <files>
            <add value="index.php" />
        </files>
    </defaultDocument>
   </system.webServer>
</configuration>

上述方法不起作用。

4

2 回答 2

0

我最终只是在 web.config 中进行了重写:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule placestoswim" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="index.php" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
于 2018-04-06T16:22:29.630 回答
0

您需要添加 clear 以删除所有继承的元素:

<configuration>
   <system.webServer>
    <defaultDocument enabled="true">
        <files>
            <clear />
            <add value="index.php" />
        </files>
    </defaultDocument>
   </system.webServer>
</configuration>

还要确保您的应用程序不是在经典模式下运行,而是在集成模式下运行。

于 2018-04-06T01:45:41.103 回答