简体   繁体   English

新域名的URL重写

[英]URL Rewrite for New Domain Name

I'm trying to create a url rewrite in IIS. 我正在尝试在IIS中创建URL重写。 We have installed a SSL cert on the server and need all connections to be HTTPS. 我们已在服务器上安装了SSL证书,并且需要所有连接均为HTTPS。 The HTTPS rewrite rule seems to be working properly. HTTPS重写规则似乎正常运行。

The issue we have is that users throughout the organization have bookmarks for the server name. 我们遇到的问题是,整个组织中的用户都有服务器名称的书签。 Because of this, they will receive a security warning about the server name not matching the certificate. 因此,他们将收到有关服务器名称与证书不匹配的安全警告。 Example: https://mywebserver/BI/Default.aspx . 例如: https://mywebserver/BI/Default.aspx

I need to rewrite the domain so that they are redirect to https://mywebserver.abcxyz.com/BI/Default.aspx 我需要重写域,以便将它们重定向到https://mywebserver.abcxyz.com/BI/Default.aspx

The current rules that I have created will redirect to HTTPS. 我创建的当前规则将重定向到HTTPS。 It will also rewrite the domain from https://mywebserver/ to https://mywebserver.abcxyz.com . 它还会将域从https:// mywebserver /重写为https://mywebserver.abcxyz.com

The problem I have is that it will not work if anything comes after the server name. 我的问题是,如果服务器名称后面出现任何内容,它将无法正常工作。 Example of domain that will not work: http://mywebserver.abcxyz.com/BI/Default.aspx 无法使用的域示例: http : //mywebserver.abcxyz.com/BI/Default.aspx

Any suggestions? 有什么建议么? This is what I currently have in my web.config. 这就是我当前在web.config中拥有的内容。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="CanonicalHostNameRule1" enabled="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^mywebserver\.abcxyz\.com$" negate="true" />
                </conditions>
                <action type="Redirect" url="http://mywebserver.abcxyz.com/{R:1}" />
            </rule>
            <rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

Try something like this and do the HTTPS as well so you won't have 2 separate redirects 尝试类似这样的事情,并且也执行HTTPS,这样就不会有2个单独的重定向

<rule name="CanonicalHostNameRule1" patternSyntax="Wildcard" stopProcessing="true">
  <match url="*" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="mywebserver.com" />
  </conditions>
  <action type="Redirect" url="https://mywebserver.abcxyz.com/{R:1}" />
</rule>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM