How does ASP implement URL-rewite?

Source: Internet
Author: User
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. To avoid confusion, we can even let the JSP Engine parse the JSP with the extension of Aspx.ProgramOr let the ASP. NET engine parse the ASP. NET program with the JSP extension. 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 technologies.URLRewriteTo change the address of a dynamic page to a static page, or change the parameter of a dynamic page to the path name or file in the static page address. Worker is actually a JSP program. Not necessarily true.

There is no doubt that static pages are friendly to search engines. However, the advantages of dynamic pages are also necessary for the convenience of site maintenance and for forums and other mechanisms requiring program control.

In addition to using the content publishing system to publish pages in static html format, we also have other options. That is static --> dynamic page ing. Here, there is a non-default module mod _ on the Apache server _Rewrite. A regular expression is used to convert a dynamic page to a static page. So that we can put me. asp? Para = 123 maps to static pages such as me/123.html. When a request for me/123.html is received, the web server automatically directs me. asp? Para = 123.

URLRewriteHow does it 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. AddedURLRewriteThe workflow of the functional web server is slightly changed. First, check whether the Address requested by the user 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:

URLRewriteWhat is the purpose?

1. Meet Search Engine Requirements
Some search engines cannot capture dynamic pages, and a large amount of information cannot be searched by potential users. UseURLRewriteTechnically, 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 useURLRewriteThe technology hides our implementation details, which makes it easy to modify and transplant, without losing PageRank at all.

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? Channel = 3 & id = 111 webpage address, certainly cannot be the eyes of the perfectionist, useURLRewriteTechnology, you can change it to http: // server/news/3/111.htm.

IIS5.0 supportURLRewrite?

The answer is simple, not supported. However, we can install the Server ExtensionIISYes.

Currently, two products are supported.IIS5.0URLRewrite, ISAPI _RewriteAndIIS Rewrite.

ISAPI _Rewrite: Http://www.helicontech.com/download/#isapi _Rewrite
IIS Rewrite: Http://www.qwerksoft.com/products/IISRewrite/Download. asp

Only ISAPIRewriteA lite version of is free, and others are trial versions. ISAPIRewriteLite version.

We use ISAPI _RewriteLite version (free version ).

Reference:

This is simplified edition of ISAPI _Rewrite. It does not support per-Virtual-site deployments, proxiing, metabase monitoring and automatic cache cleanup but all other features are supported.

Therefore, lite version does not support virtual site configuration, metadata monitoring, and automatic cache cleaning.

Metabase metadata: metabase refers to a data storage area in the memory whereIISConfiguration value. /Metabase is stored as system32 \ inetsrv
Metabase. binfile in the folder

How to proceedURLRewrite?

ISAPI _RewriteUse a regular expression to replace the expression of a 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 ISAPI _RewriteProvides a regular expression testing tool (installed 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:RewriteFormat expression of rule matching expression
Example:RewriteRule/test-([0-9] * example .html/test. asp \? Id = $1

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

References:

For Google (search engine friendly)URLDesign
Http://www.chedong.com/tech/google _URL. Html

ISAPIRewriteDocument
Http://www.isapiRewrite. Com/docs/

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.