301 Permanent REDIRECT Implementation and 302 redirect implementation method

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

In our website construction, we often encounter the need for Web page redirection: Like the site adjustment, such as changing the directory structure of the Web page, the page was moved to a new address, or the extension of the page name, If the application needs to put. PHP is changed to. html or. shtml, in which case, if not redirected, the user's favorites or the old address in the search engine database will only give access to a 404-page error message, and the access traffic is lost; and some sites that are registered with multiple domain names, You also need to redirect users who access these domain names to the main site automatically, and so on.

Common redirection methods are: Redirect, 302 redirect and Meta Fresh:

The redirect:301 represents permanent transfer (permanently moved), 301 redirects are the best way to search engine friendliness after a Web page change, and it is recommended that 301来 be used as a referral if it is not temporarily removed.

302 redirect:302 on behalf of temporary transfer (temporarily moved), in the previous years, many black Hat seo has been widely used in this technology cheating, at present, major search engines have intensified the crackdown, Like Google's previous years of business.com and recent penalties for BMW's German website. Even if the site is not objectively spam, it is easy to be mistaken for the search engine spam and be punished.

Meta Fresh: This was more prevalent 2000 years ago, but it is now rare. It is specifically through the meta instructions in the Web page, after a specific time to redirect to the new page, if the delay time is too short (about 5 seconds), will be judged as spam.

redirect realizes web redirection

IIS Server implements 301 redirect

* Open Internet Information Services Manager, right-click on the page or directory you want to redirect

* Select Redirect to URL

* Enter the URL address of the destination page to jump to in the redirect to input box

* Select Permanent redirect for resources (remember)

* Finally click "Apply"

Apache Server implements 301 redirect

In contrast, Apache is much simpler to implement than IIS. In Apache, there is a very important file. htaccess, with its settings, can achieve a lot of powerful features, 301 redirect is just one of them.

Redirect permanent/http://www.dey5.com (redirect content from directory to http://www.dey5.com)

REDIRECT permanent/index.php http://www.dey5.com/category/website-optimization/(redirect page index.php to http:// www.dey5.com/category/website-optimization/)

A more complex match can be achieved by reasonably configuring regular expressions in the redirection parameters. PHP 301 Redirect

Header ("http/1.1 moved Permanently");

Header ("location:http://www.dey5.com");

?

301 redirects under ASP

ASP. NET 301 Redirect

301 redirects under ColdFusion

<.cfheader statuscode= "statustext=" Moved Permanently >

<.cfheader name= "Location" value= "http://www.dey5.com" >

Old domain name redirected to new domain

Create a. htaccess file and write the code provided below to the file to ensure that all directories or pages of the old domain name are correctly jumped to the new domain.

Remember that. htaccess files must be placed in the root directory of the old site, and the new site will keep the same directory structure and Web files as the old site

Options +followsymlinks

Rewriteengine on

Rewriterule (. *) www.dey5.com/$1 [r=301,l]

Please change the above www.dey5.com to the domain name you want to jump to.

Note: the. htaccess file can only function on a Linux host that uses Apache with the MoD rewrite module as a Web server. Domain 301 Redirect to www level two domain name

In previous articles I have repeatedly mentioned: Www.dey5.com is a dey5.com domain two domain name, and the level two domain name and a directory between the selection and site structure optimization done a detailed analysis, interested can read two articles, website structure optimization is the most important SEO.

OK, continue to the domain 301 to the WWW two level domain implementation:

Create a. htaccess file and write the code provided below to the file to ensure that all requests from dey5.com are directed to the www.dey5.com request. Remember that. htaccess files must be placed in the root directory of the old site, and the new site will keep the same directory structure and Web files as the old site

Options +followsymlinks

Rewriteengine on

Rewritecond%{http_host} ^domain.com [NC]

Rewriterule ^ (. *) $ http://www.dey5.com/$1 [R=301,NC]

Please change the above dey5.com and www.dey5.com to the domain name you want to jump to.

Note: the. htaccess file only works on a Linux host that uses Apache with the MoD rewrite module as a Web server

301 Redirect Detection Tool

After the configuration is complete, be sure to check carefully if it is correct. The internet has many similar Server header checking tools, such as Check Server Headers tool-http Status codes Checker

Related Article

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.