在IIS上删除笨的index.php文件?(Remove index.php of Codeigni

2019-08-01 07:10发布

我明白我可以删除与下面的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文件。

你知道如何改变这种做法,它适用于一个子目录?

谢谢 :)

Answer 1:

我的WordPress根目录和子目录我笨的应用程序。 我创建了一个类似web.config喜欢你的,它保存在子目录。 我的CI应用程序并不需要在URL中的index.php了。

起初,我加入我的子目录中的<action url="myapp/index.php/{R:1}"...>并希望它可以只限于看看子目录,但失败。 我删除子目录,而让原来的,但移动web.config中的子目录和它的作品。

因此,我想,也许你可以创建不同的规则这两样东西的web.config文件,并在不同的目录中保存它们。

另一个需要注意的可能帮助:启用错误消息输出从IIS中的细节。 我用的招数,找出IIS如何查找我的文件。 这是<httpErrors errorMode="Detailed" /> <asp scriptErrorSentToBrowser="true"/>并且<system.web>部分如下:

<?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>

希望它帮助!



Answer 2:

做的web.config放在根目录下。

用户代码:

 <?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>



文章来源: Remove index.php of Codeigniter on IIS?