首页

Categories

Archives

如何使用301转向(301 Redirect ) ?

当你的网站链接或者某个网页的链接发生了改变,如何让原来在搜索引擎中收录的链接(URL)能够继续地有效,将用户导向当前的URL地址?

最有效和安全的方法是利用301 redirect,301转向能够保持你的网页的PageRank不变,从而使你过去的工作得到保证。“301”代码解释为永久性的转移。下面是几种方法进行301转向:

IIS Redirect

在IIS服务器管理器中,选择要做转向的文件或目录,按右键选择“a redirection to a URL”的按钮,输入你要指向的页面地址,选择”The exact url entered above”和”A permanent redirection for this resource”,然后选择“应用”。

Redirect in ColdFusion
< .cfheader statuscode="301" statustext="Moved permanently">
< .cfheader name="Location" value="http://www.new-url.com">

Redirect in PHP

< ?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>

Redirect in ASP
< %@ Language=VBScript %>
< %
Response.Status="301 Moved Permanently" Response.AddHeader "Location", " http://www.new-url.com"
>

Redirect in ASP .NET

用 .htaccess 文件转向
创建一个.htaccess文件,在.htaccess文件中加入:
Redirect permanent / http://www.new-url.com
或 Redirect 301 / http://www.new-url.com

[tags]301转向,301 Redirect[/tags]

  • 如何写.htaccess文件?
  • 一些mod_rewrite的例子
  • Comments (One comment)

    我个人觉得matt和你的方法都不错!

    Granite CounterTops / September 22nd, 2007, 10:02 am / #

    Post a comment