RewriteCond
RewriteCond <test-string> <pattern> [<modifier flag[,...]>]
Similar to conditional judgment, and multiple conditions, OR, AND are allowed. RewriteRule will only be executed when the Server Variable of RewriteCond matches the specified regular expression. for example:
RewriteCond %{REMOTE_ADDR} ^(127.0.0.1)$
RewriteRule ^/(.*).aspx$ /$
If the IP of the address we access to the website comes from 127.0.0.1, then RewriteRule ^/(.*).aspx$ /$ is allowed
RewriteCond %{REMOTE_ADDR} ^(127.0.0.1)$ [OR]
RewriteCond %{REMOTE_ADDR} ^(192.168.0.10)$
RewriteRule ^/(.*).aspx$ /$
Added OR for multiple conditional judgments
RewriteCond %{REMOTE_ADDR} ^(?!127.0.0.1)([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})(.*)$
RewriteRule ^/(?!)(.*)$ /
Modifier flags has two values
I=fuzzy matching
OR=Logical judgment
Judging from the functions of IIRF's RewriteCond, it is indeed very flexible. I don't know how to rewrite IIS7, hehe. Haven't seen it yet*^_&. in addition. RewriteCond's [Patterns] can take the following parameters
-d
Treats the TestString as a pathname and tests if it exists,
and is a directory.
TestString is a path name, and this path exists
-f
Treats the TestString as a pathname and tests if it exists and
is a regular file.
TestString is a path name and is an existing file
-s
Treats the TestString as a pathname and tests if it exists and
is a regular file with size greater than zero.
TestString is a path name and the file has more than 0 bytes.
Examples used in the document
(1)RewriteCond %{HTTP_URL} (/|\.htm|\.php|\.html|/[^.]*)$ [I] )
(2)RewriteCond %{REQUEST_FILENAME} !-f
(3)RewriteCond %{REQUEST_FILENAME} !-d
(4)RewriteRule ^.*$ / [U,L]
(1) If the URL is html, php, html (fuzzy match),
(2) The URL does not exist file
(3) The URL is not the requested path
(4) Jump all requests to save the original URL, and then no matching will be made to this later
In
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteRule ^/$ / [L]
IIRF other configuration properties
IterationLimit {integer} starts to match the RewriteRule group after the specified integer. If the number of RewriteRule is exceeded, the default will start from the 8th.
MaxMatchCount {integer} Total number of RewriteRule groups.
RewriteLog <filename stub> Log path
RewriteLogLevel {0,1,2,3,4,5} Login Level
A FAQ
After just installing IIRF, I tested the following URL and found that there is still the same problem as rewriting the URL before: it is impossible to override the path of the action below Form, and we use the original URL to get it is empty. Maybe you start to notice the modifiers option of RewriteRule that I wrote above [U]. We can save the original URL to the server variable. Then get it through [name]. Then rewrite the action value.
Quote:
1 Public Class FormFixerHtmlTextWriterClass FormFixerHtmlTextWriter
2 Inherits
3 Private _url As String
4 Public Sub New()Sub New(ByVal writer As TextWriter)
5 (writer)
6 _url = ("HTTP_X_REWRITE_URL")
7 End Sub
8 Public Overloads Overrides Sub WriteAttribute()Sub WriteAttribute(ByVal name As String, ByVal value As String, ByVal encode As Boolean)
9 If (Not _url Is Nothing And (name, "action", True) = 0) Then
10 value = _url
11 End If
12 (name, value, encode)
13 End Sub
14 End Class
postscript:
IIRF has been analyzed almost all the time. As can be seen from the above, the functions are indeed very powerful and the configuration is also very flexible. I found that I was slowly falling in love with it. hey-hey. What's important is. It is free and open source.