Explanation 301 permanent redirection Implementation Method

Source: Internet
Author: User
Tags website hosting

301 permanent redirection has no adverse effect on Seo, And the keyword ranking and PR level of Web Page A will be sent to web page B. If the website has changed its domain name, the website will be permanently transferred to another address, for Search Engine Optimization | Seo, it provides a friendly information for the search engine, telling it that the page has been permanently redirected, so that the search engine cannot find the page.

When to use 301 redirection

1: When a website domain name is changed, the old domain name will be redirected to the new domain name through 301 permanent redirection to save traffic loss and Seo.

2: When you need to delete some directories on the website, for example, if you want to delete the blog navigation under my blog, you can use 301 to permanently redirect to the homepage of the website.

3: If you have multiple idle domain names that need to direct to the same website, you can achieve this through 301 permanent redirection.

4: you plan to standardize the website.

How to standardize URLs

I will focus on the standardization of this website, because this is a problem that everyone can easily ignore. For example, if my domain name is not set, it will generate four URLs by default:

(1) lusongsong.com (2) www.lusongsong.com (3) lusongsong.com/default.html (4) www.lusongsong.com/default.html

If 301 redirection is not performed, the prvalue of your site's primary domain name will be distributed to several other URLs. First, query the prvalues of the above four websites. If the results are consistent, there is no standardization problem with the website. If the results are inconsistent, there is a standardization problem. At this time, we need to use 301 permanent targeting technology to standardize the website. Note that WWW is actually a second-level domain name for websites with or without www.

I know that there are two common 301 redirect settings. One is directly set through the IIS interface, and the other is to implement 301 redirect settings through code. Lu songsong suggested using server components for redirection. The following example shows how to redirect my domain name lusongsong. com301 to lusongsong.com.

1: IIS server implements 301 redirection

Open IIS, right-click Properties-website-Where to add a site, add a site, bind a Host Header, or bind multiple idle domain names. :

Open IIS, first create a new site, corresponds to a directory e: \ wwwroot \ 301web. This directory only requires two files, one default.html and one 404.htm. Right-click the webpage or directory to be redirected, select "redirect to URL", enter the address of the target page in the dialog box, and remember to select "permanent redirection of resources "; click "application. As shown in:

2: Apache server implements 301 redirection

In Apache, there is a very important file. htaccess. Through setting it, You can implement many powerful functions. 301 redirection is only one of them. Find redirect permanent/http://lusongsong.com:
Redirect permanent/old.html http://lusongsong.com: modify this sentence.

3: add the 301 redirection command to the. htaccess file.

The "mod_rewrite" technology is used, for example:

Rewriteengine on

Rewriterule ^ (. *) $ http://lusongsong.com/#1 [R = 301, l]

4: Applicable to users who use Unix network servers

Use this command to notify the search engine spider that your site file is not under this address. This is a common method.

Shape: Redirect 301/http://lusongsong.com/

5: complete 301 redirection in the system administrator configuration area of the server software

Applicable to users who use Windows Network Servers

6: bind/local DNS

If you have the permission to edit and modify local DNS records, you only need to add a record to solve this problem. If you do not have this permission, you can ask the website hosting service provider to set the DNS server accordingly.

DNS server settings

To direct blog.lusongsong.com to lusongsong.com, you only need to add an alias record in the DNS service, which can be written as a blog in cname lusongsong.com.

If you need to configure a large number of virtual domain names, you can write them as * In cname lusongsong.com. In this way, you can redirect all unset records ending with lusongsong.com to lusongsong.com.

7. Use ASP/PHP to implement 301 redirection:

ASP:

Response. Status = "301 moved permanently"

Response. addheader "location", "http://lusongsong.com /"

Response. End

PHP:

Header ("HTTP/1.1 301 moved permanently ");

Header ("Location: http://lusongsong.com /");

Exit ();

 

301 redirect code and test tools

Foreign: http://www.seoconsultants.com/tools/headers

Country: http://www.ranknow.cn/tools/redirectcheck

If result 200 is displayed, the request is successful, and the desired response header or data body will be returned with this response.

Common jump Methods

301 represents a permanent transfer. 301 redirection is the best method that is friendly to the search engine after the webpage changes the address. As long as it is not a temporary transfer, we recommend that you use 301 for the transfer.

302 indicates temporary transfer. This command can be used only when a website or webpage is temporarily moved to another location within 24 to 48 hours. Google is the only one with excellent processing capabilities for 302 redirection. In the past few years, many Seo companies have applied this technology extensively, but they are also prone to punishment.

With HTML jump: <meta HTTP-EQUIV = Refresh content = "5; url = http://www.lusongsong.com">, indicating that 5 seconds after automatically jump to the home page, you can also set the time shorter, however, it is easy for search engines to misjudge spam and be punished.

Skip with javascript: <script language = "JavaScript"> location. href = 'HTTP: // www.lusongsong.com '</SCRIPT>

What is the difference between forwarding and redirection?

In a word, forwarding is a server action, and redirection is a client action. A single request is sent at the time of forwarding. redirection is a two-request. The address bar of the forwarding will not change, and the address bar will be changed. The redirection is forwarded within the project and can be forwarded outside the project. When forwarding is used, the JSP Container uses an internal method to call the target page. The new page continues to process the same request, and the browser will not know the process. In contrast, redirection means that the first page notifies the browser to send a new page request.

How to Choose redirection or forwarding?

Generally, forwarding is faster and objects in the request can be kept. Therefore, it is the first choice. However, after forwarding, the URL in the browser still points to the start page. If you reload the current page, the start page will be called again. If you do not want to see such a situation, select forwarding.

The above is reproduced from Lu songsong's blog.

Modify the. htaccess File

Rewriteengine on
Rewritecond % {http_host} ^ bwzhang.com $ [or]

Rewritecond % {http_host} ^ ms026.com $ [or]
Rewritecond % {http_host} ^ www.ms026.com $
Rewriterule ^ (. *) $ http://www.bwzhang.com/#1 [R = 301, l]

Www.ms026.com ms026.com bwzhang.com will be redirected to www.bwzhang.com

Modify the. htaccess File

Errordocument 404/notfound. php

Set 404 page

Explanation 301 permanent redirection Implementation Method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.