如何排除IIS URL重写的目录? [英] How to exclude a directory with IIS URL rewriting?

查看:1136
本文介绍了如何排除IIS URL重写的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个domain.com/index.php和一个友好的网址规则来重定向domain.com/index.php?s=?要求。我使用带有URL重写附件的IIS网络服务器。

I have a domain.com/index.php and a friendly url rule to redirect domain.com/index.php?s=? requests. I use IIS webserver with the URL rewrite add-on.

以上工作正常。但是,对管理目录的请求存在问题...

Above works fine. However, there is a problem with requests to the admin directory...

我还有domain.com/admin/cloud/index.php,有时需要获取或发送数据(通过Ajax)。当规则处于活动状态时,数据不可用,当我删除上述规则时,数据可用。

I also have domain.com/admin/cloud/index.php, which is sometimes needed to obtain or send data (via Ajax). When the rule is active the data is not available, when I delete the above rule then the data is available.

如何使用上面的网址规则并排除所有其他请求在(或到)domain.com/admin/ ..里面?

How can I use above url rule and exclude all other requests inside (or to) domain.com/admin/.. ?

这是我目前的规则集:

<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
    <match url="^index\.php$" />
    <conditions>
        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
        <add input="{QUERY_STRING}" pattern="^s=([^=&amp;]+)$" />
    </conditions>
    <action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
    <match url="^([^/]+)/?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php?s={R:1}" />
</rule>

我尝试了很多方法,包括路径信息......但没有成功。也许有人可以给出提示?

I tried many ways, including path info... but without success. Maybe someone can give a hint?

谢谢!

推荐答案

看看这里您可以添加此规则,以便在您不想要的请求时进程来了,你可以忽略它并停止处理。

Taking a look here you could add this rule so when a request that you don't want to process comes, you can ignore it and stop processing.

应该先放置它,以便此规则在其他两个之前执行。

It should be placed first so that this rule executes before the other two.

<rule name="block" stopProcessing="true">
    <match url="^admin/cloud/index.php$" />
    <action type="None" />
</rule>

这篇关于如何排除IIS URL重写的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆