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

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

问题描述

我有一个 domain.com/index.php 和一个友好的 url 规则来重定向 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.

以上工作正常.但是对admin目录的请求有问题……

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.

如何使用上述 url 规则并排除 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天全站免登陆