我知道我可以通过以下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>
问题是我有CI安装在一个子目录(mydomain.com/codeigniter),我无法理解web.config文件。
你知道如何改变这个,所以它适用于一个子目录吗?
谢谢 :)
我有WordPress的根目录和我的CodeIgniter应用程序在一个子目录。 我创建一个类似你的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>
希望它帮助!