在 URL 重写中排除目录
我的 web.config 中有此代码
<rule name="Imported Rule 2" 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="default.asp?q={R:1}" appendQueryString="true" />
</rule>
,我希望特定目录排除此规则。 我该怎么做呢?
I have this code at my web.config
<rule name="Imported Rule 2" 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="default.asp?q={R:1}" appendQueryString="true" />
</rule>
and I want that specific directories will exclude of this rule.
How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
排除特定文件夹(
/contact/
、/presentation/
、/db/site/
- 这些文件夹中的任何内容)的处理这条规则,您可以再添加一个条件,如下所示:最好通过附加条件来执行,因为很容易阅读/理解这条规则的含义。
如果您总体上擅长正则表达式,那么您可能更喜欢这种方法:将此类条件移至匹配模式(最终您将得到相同的结果,并且速度会快一点..但更难以阅读):
To exclude specific folders (
/contact/
,/presentation/
,/db/site/
-- anything in these folders) from being processed by this rule, you can add one more condition, like this:It is good to do via additional condition because it is easy to read/understand what this rule is about.
If you are good with regex in general, then you may prefer this approach: move such condition into match pattern (you will have the same result in the end and it will be tiny bit faster .. but a bit more difficult to read):
这就是我如何让我的博客目录与 root 中的 code ignitor 和 /blog/ 中的 wordpress 一起使用。
博客文件夹还包含原始的 web.config 文件,这只是该文件的第二条规则...
This is how I got my blog directory to work with code ignitor in root and wordpress in /blog/
The blog folder also has the original web.config file which is just the second rule of this file...