URL rewrite iirf (ionic ' s Isapi Rewrite Filter) manual 1th/2 page _win server

Source: Internet
Author: User
Tags goto modifiers php and
Description

The difference between IIRF and Isapi_rewrite is that IIRF does not need to use the escape character \, and isapi_rewrite needs to use the escape character \.

introduce

IIRF is an open-source rewrite URL filter, similar to Apache URL rewrite, based on VC8.0 (which can be recompiled with visual Studio2005 or Visual C + + Express). It can run in iis5.0+, support asp,asp.net,php and many other formats. Rather than asp.net2.0 's own URL rewrite, with better performance and many of the features we need, it is important that it supports URLs with no extensions (for example: cnlbogs.com/****, You do not need to create a default default.aspx file, IIRF automatically will help you resolve, so that the URL more convenient for our memory, but also to further improve the ranking of the search? IIRF can be aspnet_isapi in advance to capture the URL we requested to process, if we visit cnlbogs.com/a.aspx, need to get cnlbogs.com/a.htm, step needs (IIS-ASPNET_ISAPI), Through IIRF, we can jump directly aspnet_isapi.dll, direct access to a.htm, you know, this way in asp.net is not possible.

IIRF with the ASP.net rewrite URL, it is also based on a regular way to match, with Log records, the request of the conditional judgment. Let's get to the point.

Installation

IIRF installation requires our manual operation to complete. But. is also very convenient.

1 will IsapiRewrite4.dll, Isapirewrite4.ini copy to C:\WINDOWS\system32\inetsrv (you can also copy to other appropriate folders below).

Isapirewrite4.ini is a IIRF configuration file, each time the file changes, IIRF will automatically reload the file, do not need to restart IIS to reload the configuration, if you modify the following INI file format is not correct, IIRF will automatically get the last correctly loaded configuration file.

2 Open IIS Manager, select Default Web site, right-click Properties, select ISAPI Filter, click Add, enter Filter Name: Ionic rewriter, copy the executable file to c:\windows\system32\ Inetsrv The following IsapiRewrite4.dll file, point "OK".

3 Restart IISAdmin service. (In Computer Management----Windows services)

4 complete.

Log

IIRF can load the INI configuration file, and the user's URL request record is saved to the specified log file. Because it has a significant performance overhead, it is recommended that the record level of its log be set to 0, with only
For ease of debugging, it can be set to 5,

Rewritelog saved log path, such as C:\temp\iirfLog.out
rewriteloglevel {0,1,2,3,4,5} log level with default value of 0

0– log is not logged
1-A little log
2-More logs
3-A more detailed log
4-Verbose log (4), and will track server variable and replacement strings.
5-Verbose log (5), including log file change events, recommended for easy debugging use

Regular

Regular grammar with. NET, just a different format. So I'm not in detail. Specific about the regular description you can use Google search.

Format:
Rewriterule <url-pattern> <replacement-string> [<modifiers>]
Url-pattern: matching regular expression (required)
Replacement-string: String to replace (required)
Modifiers: The action tag for the Rewriterule. Optional options. In the following I will explain


The default IIRF url-pattern,replacement-string is already in front of the main header.

For the sake of description, look directly at a few examples (the following example basically all source IIRF documents)


Rewriterule ^/original/(. *). php/modified/$1.aspx

Source: http://xxx/original/index.php

Goal: Http://xxx/modified/index.aspx

Rewriterule ^/dinoch/album/([^/]+)/([^/]+). (Jpg| Jpg| PNG)/chiesa/pics.aspx?d=$1&p=$2.$3

Source: yun_qi_img/1.jpg

Goal: Yun_qi_img/pics.aspxd=30&p=1.jpg

Relatively simple, mainly lies in the function of modifiers. All of its values are listed below, allowing for a combination (such as [r,l]).

R = Redirect (URL jump to <replacement-string> address)
NF = Not found (returns a 404 error to the user, but the file is not removed or remains in the Web site)
L = last Test if match (if it has already been matched, will not continue to match)
F = Forbidden (similar to NF flag)
I = do case-insensitive matching
U = Store original URL in Server Variable Http_x_rewrite_url (saves the original URL to the HTTP_X_REWRITE_URL server variable.) )

[R] or [R=code]
Just like the redirect method we used in asp.net, change the direction of the browser and jump to the new specified URL.
[R=code] allows us to specify a specific HTTP status return code. Only between 301 and 399. If this is beyond this range. The default would be to use the 302 state.
Rewriterule ^/goto.aspx?r= (. *) $ $ [R]
Source: http://xxx/goto.aspx?r=http://www.google.com/
Goal: http://www.google.com

L
It has been briefly described above. Not description

[NF]
It has been briefly described above. It can also work with Rewritecond to implement a custom 404 error request.
Especially note that the file you want to match must exist, the replacement string does not allow the file name to exist
Rewriterule ^/1008.aspx$/1.aspx [NF]
1008.aspx files need to exist, 1.aspx does not exist, otherwise it will not be normal to achieve our results.
(Strangely, I don't know if I was mistaken.) But the results of my final test are indeed the case, the documentation is not detailed, there are friends who know can tell me why.

F
Not a description.

[I]
Fuzzy matching

U
Save the original URL into the HTTP_X_REWRITE_URL server variable.
In asp.net you can use request.servervariables["Http_x_rewrite_url" to get the original value.
Current 1/2 page 12 Next read the full text

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.