最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

url重寫IIRF(Ionic's Isapi Rewrite Filter)手冊第2/2頁

 更新時間:2008年07月29日 10:18:00   作者:  
IIRF與ISAPI_Rewrite的規(guī)劃區(qū)別只在于IIRF不需要使用轉(zhuǎn)義字符\,而ISAPI_Rewrite則需要使用轉(zhuǎn)義字符\.

RewriteCond
RewriteCond <test-string> <pattern> [<modifier flag[,...]>]
類似于條件判斷,并且允許多個條件,OR,AND。只有當RewriteCond的Server Variable 匹配所指定的正則表達,RewriteRule才會執(zhí)行。比如:
RewriteCond %{REMOTE_ADDR} ^(127.0.0.1)$
RewriteRule ^/(.*).aspx$ /$1.aspx
如果我們訪問網(wǎng)站的地址的IP來源于127.0.0.1,那么,允許 RewriteRule ^/(.*).aspx$ /$1.aspx

RewriteCond %{REMOTE_ADDR} ^(127.0.0.1)$ [OR]
RewriteCond %{REMOTE_ADDR} ^(192.168.0.10)$
RewriteRule ^/(.*).aspx$ /$1.aspx
添加了OR來多個條件判斷

RewriteCond %{REMOTE_ADDR}   ^(?!127.0.0.1)([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})(.*)$
RewriteRule  ^/(?!redirected.htm)(.*)$      /redirected.htm

Modifier flags有二個值
I=模糊匹配
OR=邏輯判斷

從IIRF的RewriteCond的功能上來說,確實很靈活,不知道跟IIS7的重寫怎么樣,嘻嘻。還沒瞧見過呢*^_&。另外。RewriteCond的[Patterns]可以帶下面幾個參數(shù)
 -d
  Treats the TestString as a pathname and tests if it exists,
  and is a directory.
TestString是一個路徑名稱,并且存在這個路徑
 -f
  Treats the TestString as a pathname and tests if it exists and
  is a regular file.
TestString是一個路徑名稱,并且是一個存在的文件
  -s 
  Treats the TestString as a pathname and tests if it exists and
  is a regular file with size greater than zero.
TestString 是一個路徑名稱,并且存在文件超過0字節(jié)

如文檔所使用的例子
(1)RewriteCond %{HTTP_URL}             (/|\.htm|\.php|\.html|/[^.]*)$   [I] )
(2)RewriteCond %{REQUEST_FILENAME}     !-f
(3)RewriteCond %{REQUEST_FILENAME}     !-d                                  
(4)RewriteRule ^.*$                    /index.aspx                      [U,L]
(1)如果URL是以htm,php,html(模糊匹配),
(2)URL不是存在文件
(3)URL不是請求的路徑
(4)將所有請求跳轉(zhuǎn)到index.aspx,保存原始的URL,之后不在對此進行匹配

在如
RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla.*
RewriteRule  ^/$                 /homepage.max.html  [L]

IIRF其它配置屬性
IterationLimit {integer}從指定的integer后開始匹配RewriteRule組。如果超出RewriteRule個數(shù),默認將會從第8個開始。
MaxMatchCount {integer} RewriteRule組的總個數(shù)。
RewriteLog <filename stub> 日志路徑
RewriteLogLevel {0,1,2,3,4,5} 日志的等級

一個常見問題
在剛安裝IIRF之后就測試一下ASP.NET下面的URL,發(fā)現(xiàn)還是跟以前ASP.NET重寫URL有一樣的問題:無法改寫Form下面的action的路徑,而我們這時使用Request.RawUrl獲取原始的URL是為空的。也許你開始注意到了我上面寫過的RewriteRule的modifiers選項[U]。我們可以通過將原始的URL保存到服務(wù)器變量中。然后通過Request.ServerVariables[name]來獲取。然后重寫action的值就可以了。


Quote:
 1 Public Class FormFixerHtmlTextWriterClass FormFixerHtmlTextWriter
 2        Inherits System.Web.UI.HtmlTextWriter
 3        Private _url As String
 4        Public Sub New()Sub New(ByVal writer As TextWriter)
 5            MyBase.New(writer)
 6            _url = ForumContext.Current.Context.Request.ServerVariables("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 String.Compare(name, "action", True) = 0) Then
10                value = _url
11            End If
12            MyBase.WriteAttribute(name, value, encode)
13        End Sub
14    End Class


后記:
IIRF已經(jīng)分析的差不多了。從上面可以看出,功能確實很強大,而且配置也很靈活。發(fā)現(xiàn)自己也慢慢喜歡上它了。嘿嘿。重要的是。它是免費,開源的。

相關(guān)文章

最新評論

漯河市| 南靖县| 个旧市| 镇雄县| 哈尔滨市| 安龙县| 长丰县| 嘉祥县| 中牟县| 湖口县| 剑河县| 许昌县| 苍南县| 华宁县| 嘉兴市| 常山县| 石棉县| 偃师市| 泰安市| 毕节市| 奈曼旗| 石狮市| 武隆县| 益阳市| 大庆市| 赣榆县| 萨迦县| 惠水县| 龙泉市| 肇庆市| 汤阴县| 彭州市| 揭西县| 甘德县| 虎林市| 金坛市| 贵南县| 礼泉县| 阿克苏市| 苗栗市| 炎陵县|