301 redirects There are many ways to implement, such as IIS can, apache,php,asp and so on can be quickly set page 301 redirect Jump, let me give you the introduction of the students
This article will be the IIS, APACHE, ASP, PHP, several server-side or page terminal to explain how to set the 301 redirect, first or a brief introduction of the next redirect.
301 Redirect: Refers to a very important "automatic steering" technology-in fact, no technology, that is, URL redirection-users access to an address or directory, you can specify to jump to another address.
301 Redirect, which is the only one of all redirect methods in accordance with seo/seo.html "target=" _blank "> Search engine Rules redirect, which is also a basic term in SEO, such as: A station with www.bKjia.c0m, bkjia.c0m binding, there will be 2 weights, if the bkjia.c0m redirected to Www.bKjia.c0m, will be the weight set, the corresponding increase in weight values.
1. Set 301 redirects on the IIS server
Preparation: You need to have the server set permissions, you can freely open new virtual space!
First, create a new virtual space, you need to redirect the domain name and its resolution binding;
Second, my Computer--open "control Panel"--"Administrative Tools"-open "Internet information Service", there will be a tree menu on the left, find your website-right-click "Properties"-Select "Home Directory" tab, then "redirect to URL", Then enter the target domain name that you want to orient in the Address box, and finally, on the tab, in the "permanent Redirection of Resources" option, click "OK" to complete the operation. The property interface is set as shown in:
2, Unix/linux host on Apache set 301 redirect
Create a new. htaccess file and enter the following (you need to turn on mod_rewrite):
1) Turn the domain name without www to the domain name with www
The code is as follows |
Copy Code |
Options +followsymlinks Rewriteengine on Rewritecond%{http_host} ^bkjia.c0m [NC] Rewriterule ^ (. *) $www. bkjia.c0m/301/[l,r=301] |
2) Redirect to new domain
The code is as follows |
Copy Code |
Options +followsymlinks Rewriteengine on Rewriterule ^ (. *) $www. bkjia.c0m/301/[l,r=301] |
3) Use regular 301 steering to achieve pseudo-static
The code is as follows |
Copy Code |
Options +followsymlinks Rewriteengine on Rewriterule ^article-(. +). html$ article.php?id=$1 the article.php?id=123 to article-123.html |
3. Set 301 redirect Code in ASP program page
In the public header file or the global call file, add the following code:
The code is as follows |
Copy Code |
<%@ Language=vbscript%> <%if request. ServerVariables ("SERVER_NAME")! = "www.bKjia.c0m" Then response.status= "301 Moved Permanently" Response.AddHeader "location", "http://www.bKjia.c0m" Response.End End if%> |
Principle: Determine the server_name of the request, and whether it is the same as the main destination URL, redirect
4, PHP program page set 301 redirect
The code is as follows:(more perfect notation)
The code is as follows |
Copy Code |
$host = ' www.bKjia.c0m '; Your goal-oriented URL if ($_server[' http_host '! = $host)//If it is not redirected, the following page parameter is not changed {Header ("http/1.1 301 Moved Permanently"), header ("location:http://{$host}{$_server[request_uri]}"); } Unset ($host); |
principle:First define the target-oriented URL, and then determine whether the current request to access the host is consistent, if no, then redirect
http://www.bkjia.com/PHPjc/632814.html www.bkjia.com true http://www.bkjia.com/PHPjc/632814.html techarticle 301 Redirects There are many ways to implement, such as IIS can, apache,php,asp and so on can be quickly set page 301 redirect Jump, below I come to introduce you to introduce this article will pass ...