简体   繁体   中英

How can i configure in web.config a 301 permanent redirect?

I would love to use web.config to do the 301 redirection from an old domain to another. How could i do that?

In your answers, please keep in mind that the IIS is v7 and

i would not like to use any 3rd party dll's like urlrewriteing.net etc or use ASP.NET code or configure the IIS,for that.

I am sure this can be done, but how?

UPDATE: I tried the answer of Parvesh's but i have a feeling the is not "officially" supported OR i am making something else terribly wrong.

you will need the URL rewriting module installed under IIS and then you can use this in side web.config.

<configuration>
<system.webServer>
<rewrite>
  <rules>
    <rule name="Redirect to WWW" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^domain.com$" />
      </conditions>
      <action type="Redirect" url="http://www.domain.com/{R:0}"
           redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>
</system.webServer>
</configuration>

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