簡體   English   中英

IIS 重定向 多個域允許一個訪問文件夾 - 拒絕訪問另一個

[英]IIS redirect Multiple domains allow one access to folder - deny access to other

如何創建重定向規則以允許從 Domain2.com 訪問一個文件夾,如果從 Domain1.com 訪問,則拒絕/重定向到 root

基本上我們希望管理控制台不能從 Domain1 訪問並將其設置在 Domain2 上。

我嘗試在重定向規則中使用 negagte,但這對我來說沒有。

    <!-- Redirect Domain1 Admin to Homepage -->
    <rule name="RedirectAdmintoHomepage">
      <match url="https://www.domain1.com/admin" />
      <action type="Redirect" url="https://www.domain1.com/" />
    </rule>
    <!-- End Redirect Domain1 Admin to Homepage -->

         <rule name="Redirect .aspx to non aspx" stopProcessing="true">
                      <match url="(.*).aspx" />
                      <conditions>
                        <add input="{REQUEST_URI}" pattern="admin" negate="true" />
                        <add input="{REQUEST_URI}" pattern="userlogin" negate="true" />
                      </conditions>
                      <action type="Redirect" url="{R:1}" />
            </rule> 

                        <rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAny">
          <add input="{HTTP_HOST}" pattern="^[^www]" />
          <add input="{HTTPS}" pattern="off" />
<!-- Exclude Domain2 redirection -->
          <add input="{HTTPS}" pattern="https://console.domain2.com" negate="true" />  
<!-- Exclude Domain2 redirection -->
</conditions>
      <action type="Redirect" url="https://www.domain1.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>

總之基本上

禁止https://www.domain1.com/admin

允許https://console.domain1.com/admin (*)

您可以使用下面的 url 重寫規則來禁止https://www.domain1.com/訪問管理文件夾並允許https://.conole/

<rule name="RequestBlockingRule14" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="on" />
                    <add input="{HTTP_HOST}" pattern="www.domain1.com" />
                    <add input="{REQUEST_URI}" pattern="admin/(.*)" />
                    <add input="{HTTP_HOST}" pattern="console.domain1.com" negate="true" />
                </conditions>
                <action type="Redirect" url="https://www.domain1.com/" redirectType="Temporary" />
            </rule>

注意:您的Force WWW 和 SSL規則存在一些問題。 您需要先更正該規則。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM