301重定向怎么進行URL標(biāo)準(zhǔn)化設(shè)置?
我們在上網(wǎng)的時候經(jīng)常會碰到這樣的情況,其他網(wǎng)站鏈接你的站點時,會用下面的鏈接:
•www.example.com
•example.com/
•www.example.com/index.html
•example.com/index.php
•example.com/index.asp
而這樣導(dǎo)致:你站點主域名的權(quán)重分散到其他幾個URLs了。
如果你用301重定向把其他三個URL轉(zhuǎn)www.example.com
權(quán)重也就集中在主域名:www.example.com 了。
301重定向具體辦法:
設(shè)置.htaccess文件(只適用于linux系統(tǒng),并需要虛擬主機支持。)
使訪問example.com/的時候就會自動轉(zhuǎn)到www.example.com
在.htaccess文件里寫上以下代碼即可。
RewriteEngine on
RewriteCond %{http_host} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
了解本站的.htaceess文件設(shè)置,請 點擊這里
注意:URL標(biāo)準(zhǔn)化的301重定向(以上代碼)需要寫在其他URL-rewrite代碼之前。