25 Mar 2009 @ 7:43 PM 
 

更换域名301重定向htaccess

 

网站更换域名后,为了不失去原来域名的流量,可以采取301重定向,即可不丢流量,对搜索引擎也是友好的。当然,两个域名同时绑定也没有问题,但这样选择的结果会进入一个进退维谷的境地,显然是不明智的。

假设我们原来的域名为old.com,新鲜出炉爱不释手的域名为new.com,想让所有途径过来的old.com都定向到new.com,那么我们在根目录htaccess中加入如下:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]

如果上面的设置没有作用于子文件形如/bbs,那么在/bbs下中的htaccess加入:(代码仅为演示,请下载htaccess文件)

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/bbs/$1 [L,R=301]

附:htaccess文件下载

独立ip虚拟主机_90元起
Tags Tags: , ,
Categories: 技术文档
Posted By: admin
Last Edit: 15 Jul 2009 @ 01 50 AM

EmailPermalink
 

Responses to this post » (None)

 

Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

\/ More Options ...
Change Theme...
  • Users » 1
  • Posts/Pages » 56
  • Comments » 9
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

关于



    No Child Pages.

站长工具



    No Child Pages.

独立IP价格



    No Child Pages.