简体   繁体   English

IIS 重定向 多个域允许一个访问文件夹 - 拒绝访问另一个

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

How can I create a redirect rule to that will allow access to one folder from Domain2.com and deny/redirect to root if access from Domain1.com如何创建重定向规则以允许从 Domain2.com 访问一个文件夹,如果从 Domain1.com 访问,则拒绝/重定向到 root

Basically we want the admin console to not be access from Domain1 and set it up on Domain2.基本上我们希望管理控制台不能从 Domain1 访问并将其设置在 Domain2 上。

I tried to use negagte in the redirect rules but that did not for me.我尝试在重定向规则中使用 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>

In short basically总之基本上

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

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

you could use below url rewrite rule to disallow https://www.domain1.com/ to access the admin folder and allow https://console.domain1.com/您可以使用下面的 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>

Note: there is some issue in you Force WWW and SSL rule.注意:您的Force WWW 和 SSL规则存在一些问题。 you need to correct that rule first.您需要先更正该规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 拒绝访问文件夹内的文件,但允许 REST API - Deny access to files inside folder but allow a REST API 将多个域重定向到一个网址 - Redirect multiple domains to one url CORS 和 HTTPS 重定向的 Access-Control-Allow-Origin 问题(IIS / IISNode / NodeJS) - Access-Control-Allow-Origin issue with CORS and HTTPS redirect (IIS / IISNode / NodeJS) 多个域使用不同的设置重定向到一个站点 - Multiple domains redirect to one site with different settings 编辑.htaccess将多个域重定向到一个域 - Edit .htaccess to redirect multiple domains to one domain nginx:如何将服务器端应用程序访问重定向到正确的域(同一个 vps 上的多个域) - nginx : how redirect server side application access to correct domain ( multiple domains on same vps ) 301将多个域重定向到域IIS的子目录 - 301 redirect multiple Domains to a sub directories of a domain IIS web.config将多个域重定向到一个域,并将HTTP重定向到HTTP - web.config redirect multiple domains to one AND redirect HTTP to HTTPs HAProxy-将一个域的流量重定向到https,将其他域的流量重定向到仅http - HAProxy - Redirect traffic of one domain to https and other domains to http only 如何使用 .htaccess 访问一个文件:拒绝所有人 - How to access one file with .htaccess : deny from all
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM