首页 > 解决方案 > IIS Url Rewrite 导致 403 Forbidden

问题描述

更新

启用目录列表后,它似乎已经工作,但现在我遇到了另一个错误。

Resource interpreted as Stylesheet but transferred with MIME type text/html

我正在尝试重写 URL 以从绝对目录中获取内容。

假设我的 URL 是https://somesite.com/a <-- 绝对路径

这个目录由文件index.html, contact.html和文件夹组成css,js,img

但是我想用应该带我去的URL类似访问这个目录,但它也应该将参数保留在 URL 中,因此重定向不是一个选项,这是因为我需要从后端代码使用后面的代码。
https://somesite.com/a/somename/index
https://somesite.com/a/index
somenameReferrer Url

我的规则

<rule name="StoreRewrite" stopProcessing="true">
      <match url="^a/([^/]+)/([^/]+)" />
         <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
         <action type="Rewrite" url="a/{R:2}" />
 </rule>

上面的重定向有效,但它不会加载 html 文件中的附加内容,
例如js,css所有与 html 文件相关的文件。

当我输入 url 时显示以下错误https://somesite.com/a/someprofile/contact
页面a\contact显示但不显示其相关内容。控制台充满了这个错误

  Failed to load resource: the server responded with a status of 403 (Forbidden)

当我输入 URL 时显示以上内容

标签: htmliisurl-rewritingurl-routinghttp-status-code-403

解决方案


推荐阅读