How to do the Web site 301 Redirect (Apache/iis/htaccess) Implementation method Introduction

Source: Internet
Author: User

1) IIS 301 redirect

IIS implements the 301 permanent redirection method, which is applicable to Windows servers, and then performs the following actions: Locate the corresponding Web site in IIS-> Redirect to url-> to enter the URL address of the destination Web page in Redirect to redirect-> Select "Permanent Redirection of resources" (It must be checked here)-> "Application" can be.

2 Apache 301 Redirect

The Apache server implements 301 redirects, usually with "mod_rewrite" pseudo static technology, where the. htaccess file is needed. Small spell with domain name 301 Redirect to the two level domain name of WWW, you only need to add the following rules to the. htaccess file:
Options +followsymlinks

The code is as follows Copy Code
Rewriteengine on
Rewritecond%{http_host} ^xp-sem.com
Rewriterule ^ (. *) $ http://www.xp-sem.com/$1 [r=permanent,l]
Similarly, pseudo static technology for Windows servers can achieve 301 redirects by adding the following rules to the Httpd.ini:
Rewritecond Host: ^xp-sem.com$
Rewriterule (. *) http://www.xp-sem.com$1 [r,i]

3 Linux 301 Redirect

The code is as follows Copy Code
Redirect 301/http://www.xp-sem.com/

This is commonly used to write, through this command to tell search engine spider your site file is not under this URL.


4) PHP 301 redirect
Add the following code to the head of the page:

The code is as follows Copy Code
<?php
Header ("http/1.1 moved Permanently");
Header ("location:http://www.xp-sem.com");
?>

5 ASP 301 Redirect
<%@ Language=vbscript%>
<%
Response.status= "Moved Permanently"
Response.AddHeader "Location", "http://www.xp-sem.com"
%>

6) ASP.net 301 redirect

The code is as follows Copy Code
<script runat= "Server" >
private void Page_Load (object sender, System.EventArgs e)
{
Response.Status = "Moved Permanently";
Response.AddHeader ("Location", "http://www.xp-sem.com");
}
</script>

7)

ColdFusion 301 Redirect

The code is as follows Copy Code
<.cfheader statuscode= "301″statustext=" Moved Permanently ">
<.cfheader name= "Location" value= "http://www.xp-sem.com" >

8 binding/local DNS (domain alias jump) 301 redirect
If you have the Domain name DNS Control Panel Admin permissions, you can achieve 301 redirection by simply adding an alias record.
For example, to the blog.xp-sem.com point to www.xp-sem.com, only in the DNS service should add an alias record, can be written: blog in CNAME www.xp-sem.com;
If you need to configure a large number of virtual domain names, you can write: * in CNAME www.xp-sem.com, so that all of the settings that are not set at the end of the xp-sem.com are all redirected to www.xp-sem.com.

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.