This article explains how to set 301 redirection on IIS, APACHE, ASP, and PHP servers or page programs. 301 redirection: refers to a very important Ampersand... this article explains how to set 301 redirection on IIS, APACHE, ASP, and PHP servers or page programs.
301 redirection: it refers to a very important "automatic redirection" technology-in fact, it is not a technology, that is, URL redirection-the user can access an address or directory and specify to jump to another address.
301 redirection: this is the only redirection in all redirection methods that meets the seo search engine rules. this is also a basic term in SEO. for example, a website is bound with www.phprm.com and phprm.com, there will be two weights. if you redirect phprm.com to www.phprm.com, the weights will be concentrated and the weights will be increased accordingly.
1. set 301 redirection on the IIS server
Preparations: you need to have the server settings permission to activate a new virtual space at will!
First, create a virtual space and bind the domain name you want to redirect to with its resolution;
Second, my computer --> Open "control panel" --> "management tools" --> open "Internet information service", with a tree menu on the left, find your website, right-click "properties", select the "home directory" tab, select "redirect to URL", and enter the target domain name to be targeted in the address box, finally, select "permanent resource redirection" on the tab and click "OK" to complete the operation. Shows the property interface settings:
2. set 301 redirection for apache on Unix/linux hosts
Create a new. htaccess file and enter the following content (mod_rewrite must be enabled ):
1) switch the domain name without WWW to the domain name with WWW. the code is as follows:
Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^phprm.com [NC] RewriteRule ^(.*)$www.phprm.com/301/[L,R=301]
2) redirect to the new domain name. The code is as follows:
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$www.phprm.com/301/ [L,R=301]
3) use regular expressions to perform 301 redirection to achieve pseudo-static state. The code is as follows:
Options +FollowSymLinks RewriteEngine on RewriteRule ^article-(.+).html$ article.php?id=$1
Set article. php? Id=123the address is directed to article-123.html.
3. set the 301 redirection code on the ASP program page
Add the following code to a public header file or a global call File:
<%@ Language=VBScript %> <% if request.ServerVariables("SERVER_NAME")!="www.phprm.com" then Response.Status="301 Moved Permanently" Response.AddHeader "Location", "http://www.phprm.com" Response.End end if %>
Principle:Determine whether the server_name of the request is the same as the master target URL. if it is different, the request will be redirected.
4. set 301 redirection on the PHP program page,The code is as follows:
$ Host = 'www .phprm.com '; // your target URL if ($ _ SERVER ['http _ host']! = $ Host) // If not, the redirection is performed. the following page parameters remain unchanged {header ("HTTP/1.1 301 Moved Permanently"); header ("Location: http: // {$ host} {$ _ SERVER [REQUEST_URI]} ");}
Principle:First, define the target targeted URL, and then determine whether the currently requested hosts are consistent. If yes, redirect.
Address:
Reprinted at will, but please attach the article address :-)