Teach you to make a perfect 301 redirect

Source: Internet
Author: User

What is 301 redirect?

Usually we will encounter in the site construction, such as: Website revision, dynamic static, the structure of the relocation of the site after the adjustment and so on, in these cases, if you do not do 301 Redirect, the user access to the original address will be directly prompted 404 error page information, Very detrimental to the user experience. and will be the search engine down right, then in these cases we need to do 301 Redirect, 301 redirect It is mainly web page change address after the search engine the most friendly method, in the SEO perspective, 301 permanent redirection can increment the weight, The weight of the original page is set to one address. Very good for page weight promotion. 301 redirection is the only one in the search engine can pass the weight, and will not be a way of K, so do 301 redirect is very important for website SEO optimization

301 Redirect Effect example: Enter in the Address bar: leeseo.org can see that the effect of auto jump to www.leeseo.org is 301 redirect

Why use 301 redirects?

1, standardize the website, concentrated weight:

In the search engine seems leeseo.org and www.leeseo.org is two different websites, generally we will not take the WWW domain name redirection to the domain name with www, so you can put the weight of leeseo.org to www.leeseo.org.

2. Website revision:

Replacement of website domain name, site Directory name and site page suffix name.

How can I do 301 redirects?

301 redirect Although good, but it has certain limitations, in addition to the above mentioned in several cases to do 301 Redirect, the other need to consider is our site storage host space Support 301 redirect.

Usually we buy the host space is most commonly used in Windows and Linux two systems, the following will be said in these two situations need to achieve what conditions to do 301 redirects, and how to do 301 redirects.

1,the Linux host generally uses the Apache server, this kind of host needs to support. htaccess to do 301 redirects.

If you support. htaccess, then how do you do 301 redirects?

First, the 2 domain names with www and without www are resolved to the IP address of our host, then add the following rules at the beginning of the. htaccess file:

Rewritecond%{http_host} ^ leeseo.org [NC]

Rewriterule ^ (. *) $/HTTP/www.leeseo.org/$1 [r=301,l]

2,window host usually use IIS server is need to install isapi_rewrite this component (that is, usually with the most we say the pseudo-static environment), if support how to do 301 redirect? What should we do if we do not support them?

If the Isapi_rewrite component is supported, first resolve the 2 domain names with www and without www to the IP address of our host, and then add the following rules at the beginning of the Httpd.ini (commonly described pseudo-static rule file) file:

Rewritecond Host: ^ Leeseo \.orgt$

Rewriterule (. *) http\://www\. leeseo\.org$1 [R,i]

3, if the Isapi_rewrite component is not supported, it can only be operated through IIS (for own server or for the virtual host provider to help resolve), the steps are as follows:

First create a new Web site under IIS, the Site directory (can also create a new folder with the original site folder, casual) only need to have 2 files: Default.htm and 404.htm, the new site host header binding needs to do 301 redirect URLs, as the above example: leeseo.org need to do 301 to www.leeseo.org in the new site is bound to the host header leeseo.org, new after the completion of the new site right-click, select Properties, select the Home directory in the Properties panel, as shown in, select Redirect to the URL, Then enter the URL, and don't forget to tick the "permanent redirection of resources" option!

Reminder: The author in doing 301 redirects found on the internet listed articles are not new site this matter, so many novice friends less operation of the new site this step, resulting in 301 redirect after the site can not open the situation. Please pay attention!

How to do 301 redirects?

1, the Windows host will save the code as Httpd.ini placed in the site root directory.

[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewriteengine on
Rewritecond Host: ^mxseo\.com$
Rewriterule (. *) http\://www\.mxseo\.com$1 [I,RP]

Note: iis6.0 is used with Httpd.ini files, iis7.0 above is with the Web. config file.

2. How to set up 301 redirect using code (PHP)

<?php
$the _host = $_server[' http_host '];//get the current domain name
$the _url = isset ($_server[' Request_uri ')? $_server[' Request_uri ']: ";//Judge the address after the part
$the _url = strtolower ($the _url);//convert English letters to lowercase
if ($the _url== "/index.php")//judgment is not home
{
$the _url= "";//If it is the first page, the assignment is empty
}
if ($the _host!== ' mxseo.com ')//If the domain name is not a URL with www then proceed to the following 301 jump
{
Header (' http/1.1 301 Moved permanently ');//301 head issued
Header (' location:http://www.mxseo.com '. $the _url);//jump to the URL with www
}
?>

Call <?php include ("File name. php") in the Web page; 301 redirects?

3, using the server to do 301 redirects:

Because of the relatively simple server, Dream Star is not here to do a detailed explanation, if not clear or want to know the seoer, can add dream star QQ or Q group directly ask Dream Star can.

301 Redirect Description:

1, 301 is not hundred percent special handing weight, even with Baidu Webmaster platform is not hundred percent.

2, 301 in the transfer of weight process, need to have content similarity and time assessment.

3, if the old domain name is punished, 301 to the new domain name may also be punished.

4, can use station Group 301 technology to get the ranking.

If the webmaster is using a host that does not support the 301 redirect, the author also recommended two methods, but also can achieve the purpose of search engine friendly

1, if it is a brand-new domain name and website, not with the WWW domain name has not been included in the search engine, then you can use the way of forwarding the URL, the domain name without www forward to the domain name with www, in the domain management background can be set forward, It is worth noting that at present, some domain name registrars in the country have made certain restrictions on the site forwarding.

2, if the website has been online for a long time, did not take the domain name of WWW also included a lot, then the site navigation, classification, columns and so on some of the more important locations as far as possible using the absolute address with www

Absolute address (i.e. absolute path): like this http://www.leeseo.org/Seo-jichu/220.html

Relative address (i.e. relative path): like this/seo-jichu/220.html

Rentiyishu www.leeseo.org

Teach you to make a perfect 301 redirect

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.