Linux下301重定向怎麼做

1.登陸後台,開啟偽靜態支持2.將下面的代碼複製到.htaccess文件中,保存。(單個域名跳轉)RewriteEngine onRewriteBase /RewriteCond %{http_host} ^zzidc.com [NC]RewriteRule ^(.*)$ http://www.zzidc.com/$1 [L,R=301]

多個域名跳轉RewriteEngine onRewriteBase /RewriteCond %{http_host} ^www.mbaoo.net [NC]RewriteRule ^(.*)$ http://www.zzidc.com/$1 [L,R=301]RewriteCond %{http_host} ^www.mbaoo.com [NC]RewriteRule ^(.*)$ http://www.zzidc.com/$1 [L,R=301]

Advertisements

或者RewriteCond %{http_host} ^www\.1\.com.* [OR]RewriteCond %{http_host} ^1\.com.* [OR]RewriteCond %{http_host} ^2\.com.*RewriteRule ^(.*)$ http://www.2.com/$1 [L,R=301]

3.將.htaccesss文件上傳至站點根目錄下。

IIS 7 301 重定向代碼 加到web.config里<configuration><system.webServer><rewrite><rules><rule name="Enforce canonicalhostname" stopProcessing="true"><match url="(.*)" /><conditions><addinput="{HTTP_HOST}" negate="true" pattern="^www.zzidc.com$" /></conditions><action type="Redirect" url="http://www.zzidc.com/{R:1}" redirectType="Permanent" /></rule></rules></rewrite><defaultDocument><files><add value="index.asp" /></files></defaultDocument></system.webServer></configuration>

Advertisements

Advertisements

你可能會喜歡