修改你的web.config文件,在web.config文件中的最后一行后面添加以下代碼:
操作前建議先備份下原有web.config 文件
<rule name="ZKEYS-WWW-7174tpxnri9" stopProcessing="true">
<match url=".*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^22.cn$"/>
</conditions>
<action type="Redirect" url="http://www.sz-lawfirm.com/{R:0}" redirectType="Permanent"/>
</rule>
如果主機(jī)空間沒有web.config 完整文件是
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ZKEYS-WWW-7174tpxnri9" stopProcessing="true">
<match url=".*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^22.cn$"/>
</conditions>
<action type="Redirect" url="http://www.sz-lawfirm.com/{R:0}" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
以上規(guī)則是指域名22.cn,重定向到www.sz-lawfirm.com,僅作為參考,實(shí)際操作請將22.cn和www.sz-lawfirm.com換成您自己的域名即可
一個(gè)很重要事就是要使用“Permanent”(永久)定向。這樣做很有幫助的是,任何人鏈接你的網(wǎng)站是使用的非www地址時(shí),直接使搜索引擎的機(jī)器人在抓取作為永久移動(dòng)的鏈接。新的url將會被定義為正確的地址,因此舊的非www地址將不會被索引。
http跳轉(zhuǎn)到https 在web.config 中加入
# <rewrite>
<rules>
<rule name="https" enabled="true" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="^OFF$"/>
</conditions>
<action type="Redirect" url="http://www.sz-lawfirm.com{REQUEST_URI}" redirectType="Permanent"/>
</rule>
</rules>
# </rewrite>
即可