网络实验室

 找回密码
 注册账户
查看: 2057|回复: 0

301 Redirect ////// 301 转向

[复制链接]
admin 发表于 2007-8-20 23:55:14 | 显示全部楼层 |阅读模式
redirect is the most efficient and Search Engine Friendly method for webpage redirection. It's not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it's the safest option. The code "301" is interpreted as "moved permanently".

Below are a Couple of methods to implement URL Redirection
IIS Redirect

    * In internet services manager, right click on the file or folder you wish to redirect
    * Select the radio titled "a redirection to a URL".
    * Enter the redirection page
    * Check "The exact url entered above" and the "A permanent redirection for this resource"
    * Click on 'Apply'

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


Redirect in PHP
  1. <?
  2. Header( "HTTP/1.1 301 Moved Permanently" );
  3. Header( "Location: [url]http://www.new-url.com[/url]" );
  4. ?>
复制代码


Redirect in ASP
  1. <%@ Language=VBScript %>
  2. <%
  3. Response.Status="301 Moved Permanently" Response.AddHeader "Location", " [url]http://www.new-url.com[/url]"
  4. >
复制代码


Redirect in ASP .NET
  1. <script runat="server">
  2. private void Page_Load(object sender, System.EventArgs e)
  3. {
  4. Response.Status = "301 Moved Permanently";
  5. Response.AddHeader("Location","http://www.new-url.com");
  6. }
  7. </script>
复制代码


Redirect Old domain to New domain (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

  1. Options +FollowSymLinks
  2. RewriteEngine on
  3. RewriteRule (.*) [url]http://www.newdomain.com/[/url]$1 [R=301,L]
复制代码


Please REPLACE www.newdomain.com in the above code with your actual domain name.

In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

Redirect to www (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

  1. Options +FollowSymlinks
  2. RewriteEngine on
  3. rewritecond %{http_host} ^domain.com [nc]
  4. rewriterule ^(.*)$ [url]http://www.domain.com/[/url]$1 [r=301,nc]
复制代码


Please REPLACE domain.com and www.newdomain.com with your actual domain name.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

How to Redirect HTML

Please refer to section titled 'How to Redirect with htaccess', if your site is hosted on a Linux Server and 'IIS Redirect', if your site is hosted on a Windows Server.
您需要登录后才可以回帖 登录 | 注册账户

本版积分规则

黑屋|存档|手机|网络实验室 本站服务器由美国合租以及IDCLayer国际数据提供!!!

GMT+8, 2024-5-7 06:00 , Processed in 0.173809 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表