Application of urlrewrite in IIS 5.0/ASP Platform

Source: Internet
Author: User
Application of urlrewrite in IIS 5.0/ASP Platform

Before talking about this technical problem, I couldn't help but think of a funny story. Netcraft once made a test. According to the comparison, the extension of a large number of website pages is ASP. net or JSP/servlet. Now, Asp.. NET applications exceed JSP/servlet.

This evaluation has aroused a lot of discussions. Many JSP technicians laugh at this evaluation. The conclusion of this evaluation ignores a big problem. That is, must the pages of JSP-developed websites be. jsp?

Of course, the answer is no. In particular, websites with MVC structures often do not have the. jsp extension. This is a convention. If it is not to avoid confusion, we can even let the JSP Engine parse the JSP program with the extension aspx, or let the ASP. NET engine parse the ASP. NET program with the extension JSP. The only thing you need to do is make some choices on the server's management tools, or modify the configuration file.

In addition, we can use more powerful urlrewrite technology to change the address of a dynamic page to a static page, or to change the parameters of a dynamic page, the path name or file in the static page address. All in all, please don't trust your eyes, just let the server administrator think about it. Then, a certain .htm address is actually an asp.netprogram, and a certain .doc is actually a JSP program. Not necessarily true.

How does urlrewrite work?

Simply put, a Web server sends a file based on the address requested by the user, or runs a cgi/script and sends the running result to the user. The workflow of the Web server with the urlrewrite function is slightly changed. First, check whether the user request address is included in our replacement rules. If the address requested by the user is changed, the server transfers the file or runs cgi/script according to the new address. See:

What is the use of urlrewrite?

1. Meet Search Engine Requirements

Some search engines cannot capture dynamic pages, and a large amount of information cannot be searched by potential users. With urlrewrite technology, you can set http: // server/news. asp? Id = 111 is changed to http: // server/news/111.htm so that they will be indexed by the search engine. Although Google can capture dynamic pages, Google generally scores dynamic pages less than static pages. Therefore, it is absolutely worthwhile to change the website address to static for a website with a large amount of information published.

2. Hiding Technology to Improve website portability

Every page is marked with a clear. asp/. JSP development language. You can see at a glance what language your website uses. When changing the website language, you need to change a lot of links. In addition, if a page has modified its extension, its PageRank will also disappear from the beginning. We can use the urlrewrite technology to hide our implementation details. This makes it easy to modify and port data without losing PageRank.

3. satisfying aesthetic requirements

For website designers who are pursuing perfection, even the addresses of webpages must look concise and clear. Such as http: // server/news. asp? The webpage address of channel = 3 & id = 111 is definitely not perfect for the perfectionist. With urlrewrite technology, you can change it to http: // server/news/3/111.htm.

Does IIS 5.0 support urlrewrite?



The answer is simple, not supported. However, we can enable IIS support by installing server extensions.

Currently, two products support IIS 5.0 urlrewrite, isapi_rewrite, and IIS rewrite.

We use isapi_rewrite Lite version (free version ).

How do I set urlrewrite?

Isapi_rewrite uses a regular expression to replace the expression of the rule.

Below is a simple example where I want our users to input http: // server/test-12314.html to actually access http: // server/test. asp? Id = 12314. Then our matching expression should be/test-([0-9] * ).html, the corresponding format expression should be/test. asp \? Id = $1.

When writing regular expressions, you can use the regular expression test tool provided by isapi_rewrite (provided by default) for debugging. For example:

After matching expressions and formatting expressions are completed, we can put them in httpd. ini in the installation directory according to the following format.

Format: rewriterule matching expression format expression

Example: rewriterule/test-([0-9] * example .html/test. asp \? Id = $1

After the file is saved, you do not need to restart IIS to take effect.

References:

URL Design for Google (search engine friendly)

Http://www.chedong.com/tech/google_url.html

ISAPI rewrite documentation

Http://www.isapirewrite.com/docs/
Author's blog:Http://blog.csdn.net/tinydust/

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.