1. Set IIS 301
Internet Information Service Manager-> virtual directory-> redirect to URL, enter the target URL to be redirected, and select "permanent resource redirection ".
In IIS, you can also install the ISAPI Rewrite component to implement the mod_rewrite function in Apache. For details, see ISAPI Rewrite 3 download and common 301 rules.
2. 301 redirection code under ASP
<% @ Language = VBScript %>
<%
Response. Status = "301 Moved Permanently"
Response. AddHeader "Location", "106 /"
%>
3. 301 redirection code under ASP. Net
<Script runat = "server">
Private void Page_Load (object sender, System. EventArgs e)
{
Response. Status = "301 Moved Permanently ";
Response. AddHeader ("Location", "106/");
}
</Script>
4. PHP 301 redirection code
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: 106 /");
Exit ();
5. 301 redirection code under CGI Perl
$ Q = new CGI;
Print $ q-> redirect ("");
6. 301 redirection code under JSP
<%
Response. setStatus (301 );
Response. setHeader ("Location", "");
Response. setHeader ("Connection", "close ");
%>
7. Apache redirection code 301
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
Options + FollowSymLinks
RewriteEngine on
RewriteCond % {HTTP_HOST} ^ embeta.com [NC]
RewriteRule ^ (. *) $1 [L, R = 301]
2) redirect to a new domain name
Options + FollowSymLinks
RewriteEngine on
RewriteRule ^ (. *) $1 [L, R = 301]
3) use regular expressions for 301 redirection to achieve pseudo-static
Options + FollowSymLinks
RewriteEngine on
RewriteRule ^ news-(. +) \. html1
Add news. php? Ids0123the address is directed to news-123.html.
8. Configure 301 redirection in vhosts. conf under Apache
To achieve URL standardization, SEO usually redirects a domain name without WWW to a domain name with WWW. The configuration in vhosts. conf is as follows:
<VirtualHost *: 80>
ServerName DocumentRoot/home/embeta
</VirtualHost>
<VirtualHost *: 80>
ServerName embeta.com
RedirectMatch permanent ^/(. *) $1
</VirtualHost>
In addition to the preceding two methods in Apache, there are other configuration methods and optional parameters. We recommend that you read the Apache documentation.