How do I perform 301 redirection for a website domain name?

Source: Internet
Author: User

1. Why is 301 redirection required?

Doing a good job of 301 redirection on the website has no harm to the website's optimization ranking. On the contrary, he has a positive effect on the website's optimization ranking. The website's 301 redirection can concentrate the weight of the website's homepage; it can also standardize the website path; 301 redirection can improve the website's indexing; and 301 redirection can improve the keyword ranking of the website.

II. Under what circumstances will 301 redirection be performed?

1. When the domain name is changed, you need to redirect the domain name to the new domain name, which can transfer weights and increase the website traffic, such as Jingdong Mall.

2. When a website topic is deleted, you need to redirect the deleted topic to the homepage or corresponding topic.

3. When the website is normalized, 301 of the website is also required.

3. How to perform 301 redirection?

1. The website is a space server that uses the. htaccess file settings to achieve 301 redirection.

In linux, http://xxx.com/ to http://www.xxx.com/modify .htaccessfile, as shown below:

RewriteEngine On

RewriteCond % {HTTP_HOST }! ^ Xxx.com/$ [NC]

RewriteRule ^ (. *) $ http://www.xxx.com/#1 [L, R = 301]

If the old domain name A (http://www.xxx.com/) points to the new domain name B (http://www.111cn.net/), you can change the. htaccess file to the following code

RewriteEngine On

RewriteBase/

RewriteCond % {HTTP_HOST }! Www.xxx.com $ [NC]

RewriteRule ^ (. *) $ http://www.111cn.net/#1 [L, R = 301]

Then, modify the file name through FTP and change it to. htaccess. Then, you can refer to the setting method of the. htaccess file in linux space for 301 redirection.

2. How to set IIS

The following uses my blog as an example to redirect piaolingseo.com to www.111cn.net.

First, create a new site, which corresponds to a directory such as D: wwwrootpiaolingseocom (which can be represented by a simple file such as 301 ). Upload an index.html file and 404.html file, and then bind the domain name http://111cn.net to piaolingseocom jump

In IIS, select the site we just created, right-click the site, properties, and home directory, and select redirect to. Enter the URL such as http://www.xxx.com/, and select permanent redirection.

3. asp 301 redirection method

You can add code at the top of the default. asp or index. asp file.

<% Response. Status = "301 Moved Permanently" Response. AddHeader "Location", "http://www.111cn.net/#response.end%>

4. php301 redirection method

You can add code at the top of the index. Php file.

<? Php $ the_host = $ _ SERVER ['http _ host']; // Obtain the current domain name $ request_uri = isset ($ _ SERVER ['request _ URI '])? $ _ SERVER ['request _ URI ']: "; // determines whether the parameter if ($ the_host! = 'Www .111cn.net ') // jump to the directed address {header ('http/1.1 301 Moved Permanently'); // send the 301 header ('Location: http://www.111cn.net/'.w.request_uri ); // The address format}?>

Through the above method, we can better perform website 301 redirection and website 301 Redirection. How can we check whether the website is well performed? We can use tools to detect it, the code returned is 301, which means we have done a good job.

 

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.