What is urlrewrite used?

Source: Internet
Author: User
Tags metabase

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.

Isapi_rewrite: http://www.helicontech.com/download/#isapi_rewrite
IIS rewrite: http://www.qwerksoft.com/products/iisrewrite/download.asp

Here, only one Lite version of ISAPI rewrite is free, and others are trial versions. ISAPI rewrite Lite version.
We use isapi_rewrite Lite version (free version ). Reference:
This is simplified edition of isapi_rewrite. It does not support per-Virtual-site deployments, proxiing, metabase monitoring and automatic IC 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 where the configuration value of IIS is stored. /Metabase is stored as system32/inetsrv
Metabase. binfile in the folder

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.

 

Bytes ----------------------------------------------------------------------------------------------------------------------------

Here is an example:

First, reference the rulrewrite_2.6.jar package.

Set filter in the project web. xml and add the following:

<Filter>
<Filter-Name> urlrewritefilter </filter-Name>
<Filter-class>
Org. Tuckey. Web. Filters. urlrewrite. urlrewritefilter
</Filter-class>
<Init-param>
<Param-Name> loglevel </param-Name>
<Param-value> warn </param-value>
</Init-param>
</Filter>
<Filter-mapping>
<Filter-Name> urlrewritefilter </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping>

Add a file urlrewite. xml under the web-inf.xml with the following content:

<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype urlrewrite public "-// tuckey.org//dtd urlrewrite 3.0 // en"
Http://tuckey.org/res/dtds/urlrewrite3.0.dtd>

<Urlrewrite>
<Rule>
<Note>
-This is a common request URL rewrite-Add the request forword URL to the ". Do" processor. -Example :-
Request http: // {domain}/user/login will be forwarded
Http: // {domain}/user/login. Do-Request
</Note>
<! --> <From> ^/([_ A-Za-Z] + [_ 0-9a-za-z-/] * [_ 0-9a-za-z] + )/? $ </From -->
<From> ^/test/([A-Z] +)/([A-Z] +) $ </from>
<To type = "Forward">/test. do? Country = $1 & amp; city = $2 </to>
</Rule>

</Urlrewrite>

 

In this way, the path in the address block is:

Http: // localhost: 8080/test/China/Shanghai.

Http: // localhost: 8080/test. do? Country = China & amp; city = Shanghai.

 

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.