简体   繁体   中英

web.config redirect in IIS server

I have to redirect from a domain to another. I try different ways to do this but it doesn't work. Someone can tell me the right metod to do a redirect in web.config?

Without knowing the ways you tried, I would suggest setting up a Global URL Rewrite rule, you do this at the server level not the individual web site level.

These setting will be stored in the applicationhost.config (Server level), not the (web.config)

Below will redirect example2.com to example.com

<rule name="Redirect to new domain" stopProcessing="true">
        <match url="(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^example2\.com$" />
             </conditions>
        <action type="Redirect" url="https://www.eample.com/{R:0}" />
</rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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