您好,歡迎來到58網(wǎng)站目錄!
當(dāng)前位置:58網(wǎng)站目錄 » 站長資訊 » 小技巧 » 文章詳細(xì)

web.config下如何設(shè)置域名301重定向!

站長「蝙蝠俠」:QQ1251270088  瀏覽:1824次 時(shí)間:2015-09-24

web.config下如何設(shè)置域名301重定向!


對于草根站長而言,我們在使用虛擬主機(jī)的時(shí)候,經(jīng)常會遇到一個(gè)問題,就是301重定向,很多站長出于seo的考慮,經(jīng)常需要把,abc.com重定向到www.abc.com 


那么如何在web.config下 做301重定向呢?下面給出代碼!


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

把以上代碼,復(fù)制在TXT文檔里面,然后重命名TXT文檔為 web.config 上傳到自己的根目錄就行了!



本文地址:http://www.quema.com.cn/artinfo/2169.html
?