[英]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. 我很乐意使用web.config来执行从旧域到另一个域的301重定向。 How could i do that?
我怎么能这样做?
In your answers, please keep in mind that the IIS is v7 and 在你的答案中,请记住IIS是v7和
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. 我不想使用任何第三方DLL像urlrewriteing.net等或使用ASP.NET代码或配置IIS,为此。
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. 更新:我尝试了Parvesh的答案,但我感觉不是“正式”支持或者我正在制造其他非常错误的东西。
you will need the URL rewriting module installed under IIS and then you can use this in side web.config. 您需要在IIS下安装URL重写模块,然后您可以在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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.