1. What is 301 redirection?
301 redirection (also called 301 redirection) is a kind of status code of the header information in the HTTP data stream returned by the server when a user or a spider sends an access request to the website server, this indicates that the URL is permanently transferred to another address.
Other common status codes include:
200 indicates that everything is normal
404 webpage does not exist
302 temporary redirection
500 internal program error
There are also other methods for website redirection, such as 302 redirection, JavaScript redirection, PHP/ASP/CGI program redirection, and MetaRefresh. Apart from the 301 redirection, other methods are common cheating techniques.
II. 301 shift transfer weight
Webpage A redirects to webpage B with 301, seo/seo.html "target =" _ blank "> The search engine can be sure that webpage A Changes the address permanently or does not actually exist, the search engine regards web page B as the only valid target. This is the only method recommended by the search engine to avoid suspicion. More importantly, the accumulated page weight of web page A will be uploaded to web page B.
3. How to achieve 301 redirection
If the website uses a Linux host, you can use the. htaccess file for 301 redirection .. Htaccess is a common text file. It is created and edited using Notepad and other text editing software, and is stored in the root directory of the website.
. Htaccess file content:
| The code is as follows: |
Copy code |
|
RewriteEngine On
RewriteCond % {HTTP_HOST }! ^ Abc.com $ [NC]
RewriteRule ^ (. *) $ http://www.abc.com/#1 [L, R = 301] |
If the website uses a Windows host, you can perform the 301 transformation setting on the control panel.
Pure static HTML pages cannot perform 301 redirection. Perform JavaScript or Meta Refresh redirection in HTML, but do not perform 301 redirection. Once HTML is read, the status code 200 is returned.
For ASP or PHP, you can also perform 301 redirection.
ASP code:
| The code is as follows: |
Copy code |
|
Response. Status = "301 Moved Permanently"
Response. AddHeader "Location", "http://www.111cn.net /"
Response. End |
PHP code:
| The code is as follows: |
Copy code |
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: http://www.111cn.net /");
Exit (); |
Conclusion: the 301 change is also frequently used in website revisions, such as page deletion, address change, and url naming system change. Static dynamic URLs may also be 301, and old and dynamic URLs will be 301 to new and static URLs.