Implementing IIS 301 Redirection (redirect jump) with ISAPI rewrite

Source: Internet
Author: User
Tags to domain url forwarding

Transferred from Faraway blog http://farlee.info/archives/url-forwarding-301-redirect-apache-iis-php-asp-jsp.html

There are many ways to achieve 301 turn, such as the Apache server by modifying the. htaccess file, the asp,php program by adding 301 to the code, and so on, specifically see 301 Turn (redirect jump) implementation.

Sometimes in order to optimize the needs of SEO, to minimize the search engine index site Repeat page, which has an important task is to take the WWW and without the www top-level domain name to choose a search engine index. For Google search engines, we can use Google's preferred domain feature, and if it is the Apache server, you can also modify the. htaccess file to achieve 301 redirects, such as setting the Www.farlee.info 301 steering to Farlee.info, the realization method in the 301 steering is also introduced.

However, if the virtual host is a Windows host, IIS does not support. htaccess files, Baidu search engine does not support the preferred domain settings, then only one domain name 301 Redirect to another domain name. So how do you implement 301 redirection under IIS? In fact, many of the domestic Windows Virtual host Space support ISAPI filters, you can through the ISAPI Rewrite to implement IIS 301-turn (or call 301 Redirect, 301 jump).

What is an ISAPI Rewrite?


The ISAPI Rewrite is a third-party Rewrite component that implements the Apache-like mod_rewrite functionality under IIS. ISAPI is an abbreviation for Internet Server application program interface, meaning the Internet Service Application interface, which is based on regular expressions. Helicon Tech's ISAPI Rewrite component has a free lite version as well as a commercial version, and the free edition only supports the global httpd.conf configuration, and the Business Edition supports user-defined Httpd.ini files that support similar. htaccess configuration at the directory and site level. The ISAPI rewrite is a powerful URL processing engine, and the latest version is now 3.0.

So, as with the Apache mod_rewrite feature, Windows Host IIS can implement URL rewriting as well as 301 redirects through ISAPI filters. Here are 301 steering codes that use different versions of the ISAPI rewrite component in different situations:

ISAPI Rewrite implementation 301 steering code


1. redirect top-level domain 301 without www to domain name with www

# Isapi_rewrite 2.x version
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewritecond Host: ^farlee/.info$
Rewriterule (. *) http/://www/.farlee/.info$1 [I,RP]

# Isapi_rewrite 3.0 Version
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewritecond%{http:host} ^farlee/.info$
Rewriterule (. *) http/://www/.farlee/.info$1 [nc,r=301]

2.301 shifts between different domain names

# Isapi_rewrite 2.x version
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewritecond%{http:host} ^isapirewrite/.com$
Rewriterule (. *) http/://www/.farlee/.info$1 [nc,r=301]

# Isapi_rewrite 3.0 Version
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewritecond%{http:host} ^www/.isapirewrite/.com$
Rewriterule (. *) http/://www/.farlee/.info$1 [nc,r=301]

3. redirect page 301 to another page

# Isapi_rewrite 2.x version
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewriterule ^/oldpage.html$ Http://farlee.info/newpage.html[i,o,rp,l]

# Isapi_rewrite 3.0 Version
[Isapi_rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit 32
Rewriterule ^/oldpage.html$ Http://farlee.info/newpage.html[nc,l,r=301,o]

Note: Isapi_rewrite 1.3 is an older version of the current domestic application that can be used for URL rewriting, but is not suitable for true 301 redirects. It is recommended that you download the latest version of Isapi_rewrite 3.0. Implementation of URL forwarding and 301-redirect (redirect jump) This article describes a Isapi_rewrite 1.3 redirect code that, while it is possible for domain redirection to go smoothly under IIS, returns the 302 HTTP header instead of the 301 status code. And the code for the 301 redirect, the other pages in the blog will jump to the home page.

After this setup, your Windows IIS can also achieve 301 redirect, whether Google and Baidu search engine will not have the WWW and without the WWW domain name and create duplicate page problem.

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.