Use Isapi_rewrite to do a simple and practical 301 redirect _win server

Source: Internet
Author: User
However, for virtual host users, 301 redirection is difficult because the virtual host provider typically does not provide this setting.
But for the space where the ISAPI rewrite is installed, 301 redirects are relatively simple.
Here's an example of how you can use the ISAPI rewrite to do 301 redirects correctly.
1.3 version of the domain redirection:
Copy Code code as follows:

# for Isapi_rewrite 1.3 Redirect domain name
#重定向jb51. cn
Rewritecond Host: ^jb51.net$
Rewriterule (. *) http://jb51.cn$1 [i,r]
#重定向www. uuwar.org
Rewritecond Host: ^www.jb51.net$
Rewriterule (. *) http://www.jb51.cn$1 [i,r]

Here we're going to redirect jb51.net to jb51.cn
Because the ISAPI rewrite now uses more than two versions of the 2.x version and the 3.x version
Then the two versions of the rules are written out, the 3.0 version is incompatible with the 2.0 rule, but there is the provision of a rule converter, import can be converted.

Copy Code code as follows:

# for Isapi_rewrite 2.x
Rewritecond Host: ^maphack.org$
Rewriterule (. *) http://jb51.cn$1 [I,RP]
Rewritecond Host: ^www.maphack.org$
Rewriterule (. *) http://www.jb51.cn$1 [I,RP]

# for Isapi_rewrite 3.x
Rewritecond%{http:host} ^maphack.org$
Rewriterule (. *) http://jb51.cn$1 [nc,r=301] Rewritecond%{http:host} ^www.maphack.org$
Rewriterule (. *) http://www.jb51.cn$1 [nc,r=301]

Description: [i,rp]:i says ignore case, RP means use 301 turn, above all is the entire domain name redirects.

Single page redirection, redirect the 1.html in the root directory to http://www.jb51.cn/index.html:
Copy Code code as follows:

# for Isapi_rewrite 2.x
Rewriterule ^/1.html$ http://www.jb51.cn/index.html [i,o,rp,l]

# for Isapi_rewrite 3.x
Rewriterule ^/1.html$ http://www.jb51.cn/index.html [Nc,l,r=301,o]


Description: O indicates that the URL is standardized, L represents the last rule, and finally, the following rewrite rule does not work for him, preventing it from being rewritten again by other matching rules. The path here can be a relative or absolute path.

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.