PHP implementation 301 turn to code _ PHP Tutorial

Source: Internet
Author: User
PHP implements code 301 redirection. 301 redirection definition 301 redirection (or 301 redirection, 301 redirection) is the header of the HTTP data stream returned by the server when a user or search engine sends a browser request to the website server) definition of 301 redirection in
301 redirection (or 301 redirection, 301 redirection) is the header information in the HTTP data stream returned by the server when a user or search engine sends a browser request to the website server) indicates that the webpage is permanently transferred to another address.
Other common status codes include 200 indicating that everything is normal, 404 webpages cannot be found, and 302 temporarily switched.
Website redirection method
Website redirection methods include 301 redirection, 302 redirection, JavaScript redirection, PHP/ASP/CGI redirection, meta refresh, and so on. 302 redirection may cause URL normalization problems. Other methods are commonly used cheating methods. of course, they are not to say that they cannot be used locally. the method itself is not wrong, but many people are used by writers. search engines are sensitive to these suspicious turns. Why take risks.
301 necessity of turning
When webpage A is redirected to webpage B with 301, the search engine can be sure that webpage A changes its position permanently or does not actually exist. then, the search engine regards webpage B as the only valid target. The advantage is that,
First, there is no URL standardization problem
Second, it is also very important that the PR level of web page A will be uploaded to web page B.
Third, the record will not be included because the domain name is changed.
Implementation
CODE:
$ Url = ""];
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: $ url ");
?>
The above php code. This function can be implemented. Where should the above code be put. Take Discuz6.0 as an example.
Index. php
Archiver/index. php
Forumdisplay. php
Viewthread. php
Space. php
Tag. php
Blog. php
Find the file in the upper column of the old domain name and add the above code. Update.
Test
It's easy. use the small software curl for testing.
# Curl-I
HTTP/1.0 301 Moved Permanently
Date: Tue, 06 May 2008 06:27:39 GMT
Server: apache
Location:

If you see the above HTTP/1.0 301 Moved Permanently, it means you can. next time you click the relevant link, it will automatically switch to the new link, and the search engine will automatically update the new link.

When a user or search engine sends a browser request to the website server, the server returns the HTTP data stream in the header information (header...

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.