-
- 新聞中心
- 公司新聞
- 行業(yè)新聞
- 公司風(fēng)采
- 休閑一下
-
- 產(chǎn)品中心
- 監(jiān)控攝像機(jī)
- 門禁人行通道
- 存儲與傳輸
- 會議音響與廣播
- 防盜報警
- 其他周邊設(shè)備
添加微信咨詢
通過URL重寫規(guī)則語句實現(xiàn)301重定向
在網(wǎng)站運營的過程中,有時因一些不同的訪問要求(譬如使用http://1.uwill.com.cn訪問的是http://www.360yeah.cn/1,使用http://2.uwill.com.cn訪問的是http://www.360yeah.cn/2),需對網(wǎng)站訪問進(jìn)行重定向設(shè)置。最直接最有效的做法是通過URL重寫規(guī)則實現(xiàn)。下面給出URL重寫實現(xiàn)重定向的的一些常用范例。
注意:在設(shè)置301重定向之前務(wù)必備份相應(yīng)目錄下的.htaccess文件。(Windows主機(jī)是在/htdocs目錄下,Linux主機(jī)是在根目錄下)
1.重定向uwill.com.cn到www.360yeah.cn
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.360yeah.cn$ [NC]
RewriteRule ^(.*)$ http://www.360yeah.cn/$1 [L,R=301]
2.重定向www.360yeah.cn到uwill.com.cn
RewriteEngine On
RewriteCond %{HTTP_HOST} !^uwill.com.cn$ [NC]
RewriteRule ^(.*)$ http://uwill.com.cn/$1 [L,R=301]
3.重定向olduwill.com.cn到www.newuwill.com.cn
RewriteEngine On
RewriteCond %{HTTP_HOST} !olduwill.com.cn$ [NC]
RewriteRule ^(.*)$ http://www.newuwill.com.cn/$1 [L,R=301]
4.重定向olduwill.com.cn 到 newuwill.com.cn
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !olduwill.com.cn$ [NC]
RewriteRule ^(.*)$ http://newuwill.com.cn/$1 [L,R=301]
5.重定向uwill.com.cn/file/file.php 到 otheruwill.com.cn/otherfile/other.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.360yeah.cn$
RewriteRule ^file/file.php$ http://www.otheruwill.com.cn/otherfile/other.php [R=301,L]