简体   繁体   中英

Redirect “/” to “/web” using IIS7

I'm hosting a site where I would like for various reasons to have http://mydomain.com automatically redirect to http://mydomain.com/web while at the same time still allowing http://mydomain.com/foo.html to be served.

Using HTTP Redirect from IIS 7 I seem to be creating an endless redirect loop. Would you have any hints for me?

Give URL Rewrite Module a try. Following code should work for you :

<rewrite>
  <rules>

    <rule name="Redirect example.com to example.comn/web" patternSyntax="ECMAScript" stopProcessing="true">
        <match url="^$" />
        <action type="Redirect" url="/web" />
    </rule>

  </rules>
</rewrite>

How you can get start with Rewrite Module is briefly documented on below post :

http://www.tugberkugurlu.com/archive/remove-trailing-slash-from-the-urls-of-your-asp-net-web-site-with-iis-7-url-rewrite-module

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