Web 301 A collection of steering codes

Source: Internet
Author: User
Keywords Domain name www turn

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

1, IIS under 301 settings

Internet Information Services Manager-> virtual directory-> to a URL, enter the destination URL that needs to be redirected, and select Permanent redirect for resources.

2, ASP 301 Steering Code

<%@ Language=vbscript%>
<%
Response.status= "Moved Permanently"
Response.AddHeader "Location", "http://www.****.cn/articles/301/"
%>

3. ASP. NET 301 Steering Code

<script runat= "Server" >
private void Page_Load (object sender, System.EventArgs e)
{
Response.Status = "Moved Permanently";
Response.AddHeader ("Location", "http://www.****.cn/articles/301/");
}
</script>

4, PHP under the 301 steering code

Header ("http/1.1 moved Permanently");
Header ("location:http://www.****.cn/articles/301/");
Exit ();

5, CGI Perl 301 Steering Code

$q = new CGI;
Print $q->redirect ("http://www.****.com/");

6, JSP under the 301 steering code

<%
Response.setstatus (301);
Response.setheader ("Location", "http://www.****.cn/");
Response.setheader ("Connection", "close");
%>

7, Apache 301 Turn Code

Create a new. htaccess file and enter the following (you need to turn on mod_rewrite):

1 Change the domain name without www to the domain name with www

Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^lesishu.cn [NC]
Rewriterule ^ (. *) $ http://www.****.cn/$1 [l,r=301]

2 Redirect to new domain

Options +followsymlinks
Rewriteengine on
Rewriterule ^ (. *) $ http://www.****.cn/$1 [l,r=301]

3) using regular 301 steering to achieve pseudo static

Options +followsymlinks
Rewriteengine on
Rewriterule ^news-(. +) \.html$ news.php?id=$1

Turn news.php?id=123 Such an address to news-123.html

8, Apache lower vhosts.conf configuration 301 Turn

In order to achieve URL normalization, SEO will usually change the domain name without www to the WWW domain name, vhosts.conf is configured as:

<virtualhost *:80>
ServerName www.****.cn
Documentroot/home/lesishu
</VirtualHost>

<virtualhost *:80>
ServerName lesishu.cn
Redirectmatch permanent ^/(. *) http://www.****.cn/$1
</VirtualHost>

Apache In addition to the above 2 methods, there are other configuration methods and optional parameters, it is recommended to read the Apache document.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.