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