301 two ways to implement redirection _php tutorial

Source: Internet
Author: User
Tags addon domain
From the perspective of SEO, 301 redirection is the most feasible way to redirect URLs. When the domain name of the site changes, the search engine will only index the new URLs, but also the old address under the original external links to the new address, so that the site will not be ranked because of the change in the slightest impact. Similarly, when you use the 301 Permanent redirect command to point multiple domain names to the site's home domain, there is no negative impact on the site's ranking.

In general, there are two ways to achieve 301 redirects.

Modify the. htaccess file

The code is as follows:

 
  
   
  Rewriteengine Onrewritecond%{http_host} bkjia.com$ [Nc]rewriterule ^ (. *) $ http://bkjia.com/$1 [R=301,L]RewriteCond%{ Http_host} bkjia.info$ [Nc]rewriterule ^ (. *) $ http://bkjia.com/$1 [r=301,l]
 
  

The key code is 2 words:

Rewritecond%{http_host} bkjia.com$ [Nc]rewriterule ^ (. *) $ http://bkjia.com/$1 [r=301,l]

The domain name above is the old domain name that needs to be redirected, below is the domain name of the website now.

Using the redirect code for PHP

Create a new index.php file, and then refer to the following code to make simple changes to your own redirection requirements:

 
  

If you redirect only one domain name, you can simplify the code to the following form:

 
  

Note that the last exit () function is certain to write, I did not write initially, the result can only redirect the homepage, such as Http://www.bkjia.com/guestbook Web page, can not be redirected.

Finally, some details about redirection: If you want to redirect three domain names, before redirecting, first bind these three domain names as addon domain to my server, and let these three domains point to the same folder, so Just modify the. htaccess file or the index.php file in this folder. If you do not have a. htaccess file or a index.php file, create a new one.

http://www.bkjia.com/PHPjc/752567.html www.bkjia.com true http://www.bkjia.com/PHPjc/752567.html techarticle from the perspective of SEO, 301 redirection is the most feasible way to redirect URLs. When the domain name of the site changes, the search engine only to the new URL index, at the same time ...

  • 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.