301 PHP 301 Steering Implementation Code

Source: Internet
Author: User
301 Steering Definition
301 Steering (or 301 redirect, 301 jump) is one of the status codes in the header of the HTTP data stream that the server returns when the user or search engine sends a browse request to the Web server, indicating that the page is permanently transferred to another address.
Other common status codes include, 200 means everything is OK, 404 pages cannot be found, 302 is temporarily turned, and so on.
The way the website does the steering
The main methods of Web site steering include: 301 steering, 302 steering, JavaScript steering, php/asp/cgi steering, Meta Refresh web meta refreshes, etc. 302 steering There may be a URL normalization issue. Other methods are commonly used cheat, of course, not that can not be properly used, the method itself is not wrong, but cheated by many, search engines for these suspicious turn is very sensitive. Why take a risk?
301 Necessity of turning
When page A is redirected to page B with a 301 redirect, the search engine can confirm that page a permanently changes position, or that it does not exist, and that the search engine will treat page B as the only valid target. The advantage is that
First, there is no URL normalization issue
Second, it is also important that page A's PR page level will be uploaded to page b
Third, the inclusion will not be replaced by the domain name.
Realize

Copy the Code code as follows:


$url = "http://www.php-oa.com". $_server["Request_uri"];
Header ("http/1.1 301 Moved permanently");
Header ("Location: $url");
?>


The PHP code above. You can implement this function. Where does the code above be put? We take Discuz6.0 as an example
index.php
archiver/index.php
forumdisplay.php
viewthread.php
space.php
tag.php
blog.php
Find the original old domain name in the above file, add the above code. The update is good.
Test
It's easy. To test, use curl, the small software to check.
#curl-I. http://www.bbbb.com/sssss.php
http/1.0 301 Moved Permanently
Date:tue, May 06:27:39 GMT
Server:apache
location:http://www.jb51.net/sssss.php
If you see the above http/1.0 301 Moved Permanently, it is possible. The next time a link is linked, it will automatically turn to the new link, and the search engine will automatically update to the new link.

The above describes the 301 PHP 301 Steering Implementation code, including 301 aspects of the content, I hope to be interested in the PHP tutorial friends helpful.

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