代码之家  ›  专栏  ›  技术社区  ›  Elisabeth

不要返回索引。根url上的hmtl返回403拒绝访问

  •  0
  • Elisabeth  · 技术社区  · 8 年前

    当我进入www.mydomain时。com索引。返回html文件。

    我不想那样。

    在基本url上,我想返回403访问被拒绝, 我该怎么做 ?

    只有在附加基本url和其他路由/路径时,我才希望

    最初用于进一步的后端调用。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Bruce Chen    8 年前

    在我想要返回的基本url上,403访问被拒绝,我该怎么做?

    根据您的需求,您可以利用以下url重写规则:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
         <rewrite>
          <rules>
              <rule name="Block the request from the root url and return 403" stopProcessing="true">
                 <match url="^$" />
                 <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied."/>
                    </rule>
          </rules>
      </rewrite> 
      </system.webServer>
    </configuration>
    

    此外,您还可以删除 index.html 文档位于 Application settings > Default documents 如下所示:

    enter image description here

    推荐文章