URLREWRITE (Address Transformation) Technology Application above IIS 5.0ASP platform [Come from Tinyfool Development Diary (Blog

xiaoxiao2021-03-06  111

Before talking about this technical problem, I can't help but think of a ridiculous story.

Netcraft has made a assessment, this assessment based on the propeller of the proportion of website pages is ASP.NET or JSP / servlet, get a conclusion, now ASP.NET's application exceeds JSP / servlet.

This assessment has triggered a lot of discussion, many of the technicians using JSP laugh at this assessment. Because this evaluation conclusion ignores a big problem. That is, the page of the website developed by JSP is. JSP?

The answer is of course negative. In particular, the website of the MVC structure is often no .jsp extension, this is a practice. If not to avoid confusion, we can even let JSP engines to parse the JSP program named ASPX, or let the ASP.NET engine to parse the ASP.NET program named JSP. The only thing you need to do is to do some choices on the server's management tool, or modify the configuration file, etc.

In addition, we can also use more powerful technology URLREWRITE to turn the address of the dynamic page as a static page, or turn the parameters of the dynamic page into a path name or file in a static page address, and the like. So, sometimes, please don't believe your eyes, as long as the server administrator wants to do it, then maybe a .htm address is actually an ASP.NET program, one .DOC is actually a JSP program. Seeing is not necessarily true.

How does URLREWRITE do? Simply put, a Web Server works to send a file based on the address requested by the user, or run a CGI / script, and send the run results to the user. The WEB Server for the URLREWRITE function is slightly changed, and the first is to see if the user requested is included in our replacement rules. If you are, first changing the address requested by the user, then the server is transmitted or the CGI / script executes in accordance with the new address. See the figure below:

What is the use of URLREWRITE?

1. Meet the search engine requirements Some search engines cannot support the capture of dynamic pages, and a lot of information cannot be searched by a potential user. Use URLREWRITE technology you can turn http: //server/news.asp? Id = 111 to http: //server/news/111.htm This will be included in the search engine. Although Google can capture dynamic pages, Google's score for dynamic pages is generally lower than static pages. Therefore, the website issued by a large amount of information is definitely worth it.

2, hidden technology implementation, improve the location of the website, all the page hangs clear .asp / .jsp This development language mark can be seen in a glance that your website is doing. And when changing the language of the website, you need to change a lot of links. Moreover, a page modifies the extension, and his PageRank will disappear and start from the beginning. We can use Urlrewrite technology to hide our implementation details, so modifying transplant is very convenient, and it does not lose PageRank.

3, meet the requirements of aesthetics

For website designers who pursue perfectionism, even if the address of the webpage, it seems to be simple and clear. The web address of http://server/news.asp? Channel = 3 & ID = 111 is definitely not a perfection of perfection, with URLREWRITE technology, you can turn him into http: // server / news / 3 / 111.htm.

Is IIS 5.0 support URLREWRITE?

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

There are currently two products that support URLREWRITE of IIS 5.0.

Isapi_rewrite and IIS Rewrite.

We use Isapi_rewrite Lite Version (free version).

How to make URLREWRITE settings?

Isapi_rewrite uses the regular expression to replace the replacement rule.

Here is a simple example, I want our user to enter http: //server/test-12314.html actually access http: //server/test.asp? Id = 12314. Then our matching expression should be /test-([0-9]* ).html corresponds to /test.asp/?id= $ 1.

When preparing for regular expressions, you can use the regular expression test tool (default installation) provided by ISAPI_rewrite to debug. As shown below:

Do a good job in matching expressions and format expressions, we can put them in httpd.ini in the installation directory as follows.

Format: ReWriterule match expression formatted expression

Just now: shutriterule /test-([0-9]*).html /test.asp/?id= $ 1

Once the file is saved, you don't need to restart IIS.

Reference:

URL design for Google (Search Engine Friendly)

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

Isapi Rewrite documentation

http://www.isapireWrite.com/docs/

转载请注明原文地址:https://www.9cbs.com/read-103053.html

New Post(0)