Home >Backend Development >PHP Tutorial >Iis, apache and PHP page setting 301 redirect jump method_PHP tutorial
There are many ways to implement 301 redirection, such as iis, apache, php, asp, etc., you can quickly set up page 301 redirection. Let me introduce it to you.
This article will pass IIS, APACHE, ASP, and PHP servers or page terminals respectively explain how to set up 301 redirection. First, let’s briefly introduce redirection.
301 redirection: refers to a very important "automatic redirection" technology - actually not a technology, that is, URL redirection - when users visit an address or directory, they can specify to jump to another address.
301 redirection, this is the only redirection among all redirection methods that conforms to seo/seo.html" target="_blank">search engine rules. This is also a basic term in SEO, for example: a website uses www.bKjia. When c0m and bKjia.c0m are bound, there will be two weights. If bKjia.c0m is redirected to www.bKjia.c0m, the weights will be concentrated and the weight value will be increased accordingly
.
1. Set up 301 redirection on the IIS server
Preparation work: You must have server setting permissions and you can open a new virtual space at will!
First, create a new virtual space and bind the domain name you need to redirect to;
Second, My Computer-->Open "Control Panel"-->"Administrative Tools"-->Open "Internet Information Services", there will be a tree menu on the left, find your website--right click" Properties"--Select the "Home Directory" tab, then select "Redirect to URL", then enter the target domain name that needs to be directed in the address box, and finally select "Permanent redirection of resources" in the tab and click "OK" to complete the operation. Property interface settings, as shown below:
2. Set apache 301 redirection on the Unix/linux host
The code is as follows | Copy code | ||||
Options +FollowSymLinks
RewriteRule ^(.*)$www.bKjia.c0m/301/[L,R=301] |
代码如下 | 复制代码 |
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$www.bKjia.c0m/301/ [L,R=301] |
The code is as follows | Copy code |
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$www.bKjia.c0m/301/ [L,R=301] |
代码如下 | 复制代码 |
Options +FollowSymLinks RewriteEngine on RewriteRule ^article-(.+).html$ article.php?id= 将article.php?id=123这样的地址转向到article-123.html |
The code is as follows | Copy code |
Options +FollowSymLinks RewriteEngine on RewriteRule ^article-(.+).html$article .php?id=$1 Redirect the address like article.php?id=123 to article-123.html |
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 whether the requested server_name is the same as the main target URL. If not, redirect
|
(more perfect way of writing)