IIS 7 URL 重写 - 403 错误

标签 iis url-rewriting

我知道这个问题以前曾被问过,但我还没有找到我遇到的问题的答案。我正在尝试将域(不是子域)重定向到子文件夹。我正在运行 IIS 7,并且创建了如下 URL 重写规则:

<rule name="subfolder" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="^(www\.)?domain.com$" />
        <add input="{PATH_INFO}" pattern="subfolder" negate="true" />
    </conditions>
    <action type="Rewrite" url="/subfolder/{R:0}" />
</rule>

关闭规则后,我可以导航到类似 http://domain.com/subfolder/index.htm 的页面。启用此功能后,当我尝试导航到 http://domain.com/index.htm 时,会收到 403 错误。 .

403 - Forbidden: Access is denied.

You do not have permission to view this directory or page using the credentials that you supplied.

如何解决这个问题?

最佳答案

尝试这个简单的规则:

<rule name="Redirect domain to sub-folder" stopProcessing="true">
    <match url="^$" />
    <action type="Redirect" url="http://domain.com/subfolder" />
</rule>

关于IIS 7 URL 重写 - 403 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10116249/

相关文章:

c# - 在后面的代码上写重写规则

sql-server - IIS 错误 : Cannot connect to the configuration database

php - 在 Windows PHP 5.3.5 中使用 php_fileinfo.dll 和 finfo_open

java - Spring 从 root 上设置的 urlrewrite 规则中排除页面

php - 重写 URL 的 Glype (nginx)

Apache 重写规则 - 防止重写的 URL 出现在浏览器 URL 栏中

xml - Azure 网站上的尾部斜杠

asp.net - IIS 仅将域的 http 重定向到 https

.net - 在 IIS 中托管 .NET 服务(无接口(interface))

javascript - 使用 js 更改 url 参数,无需在单击按钮时重新加载页面