Windows 是否删除IIS上Codeigniter的index.php?

Windows 是否删除IIS上Codeigniter的index.php?,windows,codeigniter,iis,url-rewriting,Windows,Codeigniter,Iis,Url Rewriting,我知道我可以使用以下web.config代码删除url的'index.php'部分: <rewrite> <rules> <rule name="Rule" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions>

我知道我可以使用以下web.config代码删除url的'index.php'部分:

<rewrite>
  <rules>
    <rule name="Rule" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

问题是我在一个子目录(mydomain.com/codeigniter)中安装了CI,并且我在理解web.config文件时遇到问题


您知道如何更改它,使其适用于子目录吗?

我的根目录中有WordPress,子目录中有CodeIgniter应用程序。我创建了一个与您类似的
web.config
,并将其保存在子目录中。我的CI应用程序不再需要url中的index.php

首先,我在
中添加了我的子目录,希望它能被限制为只查看子目录,但失败了。我删除了子目录并将其保留为原始目录,但将web.config移动到子目录,它就可以工作了

因此,我认为您可以创建两个具有不同规则的web.config文件,并将它们保存在不同的目录中

另一个注意事项可能会有所帮助:启用错误消息以从IIS输出详细信息。我使用这些技巧来了解IIS如何查找我的文件。它是
,以及
部分,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <system.webServer>

        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>

        <rewrite>
        <rules>
            <rule name="RuleRemoveIndex" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true"/>
            </rule>
        </rules>
        </rewrite>

    </system.webServer>

    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>

</configuration>

将web.config放入根目录

用户代码:



您是否尝试将子文件夹添加到“重写url”路径<代码>谢谢!这是有效的,但前提是我的第一条规则不存在。我实际上需要两个,一个用于顶部目录,一个用于子目录。
 <?xml version="1.0" encoding="UTF-8"?>
  <configuration>
 <system.webServer>

    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true"/>

    <rewrite>
    <rules>
        <rule name="RuleRemoveIndex" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true"/>
        </rule>
    </rules>
    </rewrite>

</system.webServer>

<system.web>
    <customErrors mode="Off"/>
    <compilation debug="true"/>
</system.web>