欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ISAPI Rewrite 非官方中文配置手冊_藍(lán)色版本第3/3頁

 更新時間:2007年07月06日 00:00:00   作者:  


以下為句法

Repeats

A repeat is an expression that is repeated an arbitrary number of times. An expression followed by "*" can be repeated any number of times including zero. An expression followed by "+" can be repeated any number of times, but at least once. An expression followed by "?" may be repeated zero or one times only. When it is necessary to specify the minimum and maximum number of repeats explicitly, the bounds operator "{}" may be used, thus "a{2}" is the letter "a" repeated exactly twice, "a{2,4}" represents the letter "a" repeated between 2 and 4 times, and "a{2,}" represents the letter "a" repeated at least twice with no upper limit. Note that there must be no white-space inside the {}, and there is no upper limit on the values of the lower and upper bounds. All repeat expressions refer to the shortest possible previous sub-expression: a single character; a character set, or a sub-expression grouped with "()" for example.

Examples:

"ba*" will match all of "b", "ba", "baaa" etc.

"ba+" will match "ba" or "baaaa" for example but not "b".

"ba?" will match "b" or "ba".

"ba{2,4}" will match "baa", "baaa" and "baaaa".

Non-greedy repeats

Non-greedy repeats are possible by appending a '?' after the repeat; a non-greedy repeat is one which will match the shortest possible string.

For example to match html tag pairs one could use something like:

"<\s*tagname[^>]*>(.*?)<\s*/tagname\s*>"

In this case $1 will contain the text between the tag pairs, and will be the shortest possible matching string.

Parenthesis

Parentheses serve two purposes, to group items together into a sub-expression, and to mark what generated the match. For example the expression "(ab)*" would match all of the string "ababab". All sub matches marked by parenthesis can be back referenced using \N or $N syntax. It is permissible for sub-expressions to match null strings. Sub-expressions are indexed from left to right starting from 1, sub-expression 0 is the whole expression.

Non-Marking Parenthesis

Sometimes you need to group sub-expressions with parenthesis, but don't want the parenthesis to spit out another marked sub-expression, in this case a non-marking parenthesis (?:expression) can be used. For example the following expression creates no sub-expressions:

"(?:abc)*"

Alternatives

Alternatives occur when the expression can match either one sub-expression or another, each alternative is separated by a "|". Each alternative is the largest possible previous sub-expression; this is the opposite behaviour from repetition operators.

Examples:

"a(b|c)" could match "ab" or "ac".

"abc|def" could match "abc" or "def".

Sets

A set is a set of characters that can match any single character that is a member of the set. Sets are delimited by "[" and "]" and can contain literals, character ranges, character classes, collating elements and equivalence classes. Set declarations that start with "^" contain the compliment of the elements that follow.

Examples:

Character literals:

"[abc]" will match either of "a", "b", or "c".

"[^abc] will match any character other than "a", "b", or "c".

Character ranges:

"[a-z]" will match any character in the range "a" to "z".

"[^A-Z]" will match any character other than those in the range "A" to "Z".

Character classes

Character classes are denoted using the syntax "[:classname:]" within a set declaration, for example "[[:space:]]" is the set of all whitespace characters. The available character classes are:

alnum Any alpha numeric character.

alpha Any alphabetical character a-z and A-Z. Other characters may also be included depending upon the locale.

blank Any blank character, either a space or a tab.

cntrl Any control character.

digit Any digit 0-9.

graph Any graphical character.

lower Any lower case character a-z. Other characters may also be included depending upon the locale.

print Any printable character.

punct Any punctuation character.

space Any whitespace character.

upper Any upper case character A-Z. Other characters may also be included depending upon the locale.

xdigit Any hexadecimal digit character, 0-9, a-f and A-F.

word Any word character - all alphanumeric characters plus the underscore.

unicode Any character whose code is greater than 255, this applies to the wide character traits classes only.

There are some shortcuts that can be used in place of the character classes:

\w in place of [:word:]

\s in place of [:space:]

\d in place of [:digit:]

\l in place of [:lower:]

\u in place of [:upper:]

Collating elements

Collating elements take the general form [.tagname.] inside a set declaration, where tagname is either a single character, or a name of a collating element, for example [[.a.]] is equivalent to [a], and [[.comma.]] is equivalent to [,]. ISAPI_Rewrite supports all the standard POSIX collating element names, and in addition the following digraphs: "ae", "ch", "ll", "ss", "nj", "dz", "lj", each in lower, upper and title case variations. Multi-character collating elements can result in the set matching more than one character, for example [[.ae.]] would match two characters, but note that [^[.ae.]] would only match one character.

Equivalence classes

Equivalenceclassestakethegeneralform[=tagname=] inside a set declaration, where tagname is either a single character, or a name of a collating element, and matches any character that is a member of the same primary equivalence class as the collating element [.tagname.]. An equivalence class is a set of characters that collate the same, a primary equivalence class is a set of characters whose primary sort key are all the same (for example strings are typically collated by character, then by accent, and then by case; the primary sort key then relates to the character, the secondary to the accentation, and the tertiary to the case). If there is no equivalence class corresponding to tagname, then [=tagname=] is exactly the same as [.tagname.].

To include a literal "-" in a set declaration then: make it the first character after the opening "[" or "[^", the endpoint of a range, a collating element, or precede it with an escape character as in "[\-]". To include a literal "[" or "]" or "^" in a set then make them the endpoint of a range, a collating element, or precede with an escape character.

Line anchors

An anchor is something that matches the null string at the start or end of a line: "^" matches the null string at the start of a line, "$" matches the null string at the end of a line.

Back references

A back reference is a reference to a previous sub-expression that has already been matched, the reference is to what the sub-expression matched, not to the expression itself. A back reference consists of the escape character "\" followed by a digit "1" to "9", "\1" refers to the first sub-expression, "\2" to the second etc. For example the expression "(.*)\1" matches any string that is repeated about its mid-point for example "abcabc" or "xyzxyz". A back reference to a sub-expression that did not participate in any match, matches the null string. In ISAPI_Rewrite all back references are global for entire RewriteRule and corresponding RewriteCond directives. Sub matches are numbered up to down and left to right beginning from the first RewriteCond directive of the corresponding RewriteRule directive, if there is one.

Forward Lookahead Asserts

There are two forms of these; one for positive forward lookahead asserts, and one for negative lookahead asserts:

"(?=abc)" matches zero characters only if they are followed by the expression "abc".

"(?!abc)" matches zero characters only if they are not followed by the expression "abc".

Word operators

The following operators are provided for compatibility with the GNU regular expression library.

"\w" matches any single character that is a member of the "word" character class, this is identical to the expression "[[:word:]]".

"\W" matches any single character that is not a member of the "word" character class, this is identical to the expression "[^[:word:]]".

"\<" matches the null string at the start of a word.

"\>" matches the null string at the end of the word.

"\b" matches the null string at either the start or the end of a word.

"\B" matches a null string within a word.

Escape operator

The escape character "\" has several meanings.

The escape operator may introduce an operator for example: back references, or a word operator.

The escape operator may make the following character normal, for example "\*" represents a literal "*" rather than the repeat operator.

Single character escape sequences:

The following escape sequences are aliases for single characters:

Escape sequence Character code Meaning

\a 0x07 Bell character.

\t 0x09 Tab character.

\v 0x0B Vertical tab.

\e 0x1B ASCII Escape character.

\0dd 0dd An octal character code, where dd is one or more octal digits.

\xXX 0xXX A hexadecimal character code, where XX is one or more hexadecimal digits.

\x{XX} 0xXX A hexadecimal character code, where XX is one or more hexadecimal digits, optionally a unicode character.

\cZ z-@ An ASCII escape sequence control-Z, where Z is any ASCII character greater than or equal to the character code for '@'.

Miscellaneous escape sequences:

The following are provided mostly for perl compatibility, but note that there are some differences in the meanings of \l \L \u and \U:

Escape sequence Meaning

\w Equivalent to [[:word:]].

\W Equivalent to [^[:word:]].

\s Equivalent to [[:space:]].

\S Equivalent to [^[:space:]].

\d Equivalent to [[:digit:]].

\D Equivalent to [^[:digit:]].

\l Equivalent to [[:lower:]].

\L Equivalent to [^[:lower:]].

\u Equivalent to [[:upper:]].

\U Equivalent to [^[:upper:]].

\C Any single character, equivalent to '.'.

\X Match any Unicode combining character sequence, for example "a\x 0301" (a letter a with an acute).

\Q The begin quote operator, everything that follows is treated as a literal character until a \E end quote operator is found.

\E The end quote operator, terminates a sequence begun with \Q.

What gets matched?

The regular expression will match the first possible matching string, if more than one string starting at a given location can match then it matches the longest possible string. In cases where their are multiple possible matches all starting at the same location, and all of the same length, then the match chosen is the one with the longest first sub-expression, if that is the same for two or more matches, then the second sub-expression will be examined and so on. Note that ISAPI_Rewrite uses MATCH algorithm. The result is matched only if the expression matches the whole input sequence. For example:

RewriteCond URL ^/somedir/.* #will match any request to somedir directory and subdirectories, while

RewriteCond URL ^/somedir/ #will match only request to the root of the somedir.

Special note about "pathological" regular expressions

ISAPI_Rewrite uses a very powerful regular expressions engine Regex++ written by Dr. John Maddock. But as any real thing it's not ideal: There exists some "pathological" expressions which may require exponential time for matching; these all involve nested repetition operators, for example attempting to match the expression "(a*a)*b" against N letter a's requires time proportional to 2N. These expressions can (almost) always be rewritten in such a way as to avoid the problem, for example "(a*a)*b" could be rewritten as "a*b" which requires only time linearly proportional to N to solve. In the general case, non-nested repeat expressions require time proportional to N2, however if the clauses are mutually exclusive then they can be matched in linear time - this is the case with "a*b", for each character the matcher will either match an "a" or a "b" or fail, where as with "a*a" the matcher can't tell which branch to take (the first "a" or the second) and so has to try both.

Boost 1.29.0 Regex++ could detect "pathological" regular expressions and terminate theirs matching. When a rule fails ISAPI_Rewrite sends "500 Internal Server error - Rule Failed" status to a client to indicate configuration error. Also the failed rule is disabled to prevent performance losses

Format string syntax

In format strings, all characters are treated as literals except: "(", ")", "$", "\", "?", ":".

To use any of these as literals you must prefix them with the escape character \

The following special sequences are recognized:

Grouping:

Use the parenthesis characters ( and ) to group sub-expressions within the format string, use \( and \) to represent literal '(' and ')'.

Sub-expression expansions:

The following perl like expressions expand to a particular matched sub-expression:

$` Expands to all the text from the end of the previous match to the start of the current match, if there was no previous match in the current operation, then everything from the start of the input string to the start of the match.

$' Expands to all the text from the end of the match to the end of the input string.

$& Expands to all of the current match.

$0 Expands to all of the current match.

$N Expands to the text that matched sub-expression N.

Conditional expressions:

Conditional expressions allow two different format strings to be selected dependent upon whether a sub-expression participated in the match or not:

?Ntrue_expression:false_expression

Executes true_expression if sub-expression N participated in the match, otherwise executes false_expression.

Example: suppose we search for "(while)|(for)" then the format string "?1WHILE:FOR" would output what matched, but in upper case.

Escape sequences:

The following escape sequences are also allowed:

\a The bell character.

\f The form feed character.

\n The newline character.

\r The carriage return character.

\t The tab character.

\v A vertical tab character.

\x A hexadecimal character - for example \x0D.

\x{} A possible unicode hexadecimal character - for example \x{1A0}

\cx The ASCII escape character x, for example \c@ is equivalent to escape-@.

\e The ASCII escape character.

\dd An octal character constant, for example \10

Examples例子

Emulating host-header-based virtual sites on a single site

例如你在兩個域名注冊www.site1.com 和 www.site2.com,現(xiàn)在你可以創(chuàng)建兩個不同的站點(diǎn)而使用單一的物理站點(diǎn)。把以下規(guī)則加入到你的httpd.ini 文件

[ISAPI_Rewrite]

#Fix missing slash char on folders

RewriteCond Host: (.*)

RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]

#Emulate site1

RewriteCond Host: (?:www\.)?site1\.com

RewriteRule (.*) /site1$1 [I,L]

#Emulate site2

RewriteCond Host: (?:www\.)?site2\.com

RewriteRule (.*) /site2$1 [I,L]

現(xiàn)在你可以把你的站點(diǎn)放在/site1 和 /site2 目錄中.

或者你可以應(yīng)用更多的類規(guī)則:

[ISAPI_Rewrite]

#Fix missing slash char on folders

RewriteCond Host: (.*)

RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]

RewriteCond Host: (www\.)?(.+)

RewriteRule (.*) /$2$3

為站點(diǎn)應(yīng)該命名目錄為 /somesite1.com, /somesite2.info, etc.

Using loops (Next flag) to convert request parameters

假如你希望有物理URL如 http://www.myhost.com/foo.asp?a=A&b=B&c=C 使用請求如 http://www.myhost.com/foo.asp/a/A/b/B/c/C 參數(shù)數(shù)量可以從兩個請求之間變化

至少有兩個解決辦法。你可以簡單的為每一可能的參數(shù)數(shù)量添加一個分隔規(guī)則或者你可以使用一個技術(shù)說明如下面的例子

ISAPI_Rewrite]

RewriteRule (.*?\.asp)(\?[^/]*)?/([^/]*)/([^/]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]

這個規(guī)則將從請求的URL中抽取一個參數(shù)追加在請求字符的末尾并且從頭重啟規(guī)則進(jìn)程。所以它將循環(huán)直到所有參數(shù)被移動到適當(dāng)?shù)奈恢?,或者直到超過RepeatLimit

也存在許多這個規(guī)則的變種。但使用不同的分隔字符,例如。使用URLS如http://www.myhost.com/foo.asp~a~A~b~B~c~C 可以應(yīng)中下面的規(guī)則:

ISAPI_Rewrite]

RewriteRule (.*?\.asp)(\?[^~]*)?~([^~]*)~([^~]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]

Running servers behind IIS

假如我們有一個內(nèi)網(wǎng)服務(wù)器運(yùn)行IIS而幾個公司服務(wù)器運(yùn)行其他平臺,這些服務(wù)器不能從INTERNET直接進(jìn)入,而只能從我們公司的網(wǎng)絡(luò)進(jìn)入,有一個簡單的例子可以使用代理標(biāo)記映射其他服務(wù)器到IIS命名空間:

[ISAPI_Rewrite]

RewriteProxy /mappoint(.+) http\://sitedomain$1 [I,U]

Moving sites from UNIX to IIS

這個規(guī)則可以幫助你把URL從 /~username 改變到 /username 和從 /file.html 改變到 /file.htm. 這個在你僅僅把你的站從UNIX移動到IIS并且保持搜索引擎和其他外部頁面對老頁面的連接時是有用的

[ISAPI_Rewrite]

#redirecting to update old links

RewriteRule (.*)\.html $1.htm

RewriteRule /~(.*) http\://myserver/$1 [R]

Moving site location

許多網(wǎng)管問這樣的問題:他們要重定向所有的請求到一個新的網(wǎng)絡(luò)服務(wù)器,當(dāng)你需要建立一個更新的站點(diǎn)取代老的的時候經(jīng)常出現(xiàn)這樣的問題,解決方案是用ISAPI_Rewrite 于老服務(wù)器中

[ISAPI_Rewrite]

#redirecting to update old links

RewriteRule (.+) http\://newwebserver$1 [R]

Browser-dependent content

Dynamically generated robots.txt

robots.txt是一個搜索引擎用來發(fā)現(xiàn)能不能被索引的文件,但是為一個大站創(chuàng)建一個有許多動態(tài)內(nèi)容的這個文件是很復(fù)雜的工作,我們可以寫一個robots.asp script

現(xiàn)在使用單一規(guī)則生成 robots.txt

[ISAPI_Rewrite]

RewriteRule /robots\.txt /robots.asp

Making search engines to index dynamic pages

站點(diǎn)的內(nèi)容存儲在XML文件中,在服務(wù)器上有一個/XMLProcess.asp 文件處理XML文件并返回HTML到最終用戶,URLS到文檔有如下形式

http://www.mysite.com/XMLProcess.asp?xml=/somdir/somedoc.xml

但是許多公共引擎不能索引此類文檔,因?yàn)閁RLS包含問號(文檔動態(tài)生成),

ISAPI_Rewrite可以完全消除這個問題

[ISAPI_Rewrite]

RewriteRule /doc(.*)\.htm /XMLProcess.asp\?xml=$1.xml

現(xiàn)在使用如同http://www.mysite.com/doc/somedir/somedoc.htm的URL進(jìn)入文檔,搜索引擎將不知道不是somedoc.htm 文件并且內(nèi)容是動態(tài)生成的

Negative expressions (NOT

有時當(dāng)模式不匹配你需要應(yīng)用規(guī)則,這種情況下你可以使用在規(guī)則表達(dá)式中稱為Forward Lookahead Asserts

例如你需要不使用IE把所有用戶移動到別的地點(diǎn)

[ISAPI_Rewrite]

# Redirect all non Internet Explorer users

# to another location

RewriteCond User-Agent: (?!.*MSIE).*

RewriteRule (.*) /nonie$1

Dynamic authentification

例如我們在站點(diǎn)上有一些成員域,我們在這個域上需要密碼保護(hù)文件而我們不喜歡用BUILT-IN服務(wù)器安全,這個情況下可以建立一個ASP腳本(稱為proxy.asp),這個腳本將代理所有請求到成員域并且檢查請求允許,這里有一個簡單的模板你可以放進(jìn)你自己的授權(quán)代碼

現(xiàn)在我們要通過配置 ISAPI_Rewrite 通過這個頁面代理請求:

[ISAPI_Rewrite]

# Proxy all requests through proxy.asp

RewriteRule /members(.+) /proxy.asp\?http\://mysite.com/members$1

保護(hù)圖片 防止盜鏈
Blocking inline-images (stop hot linking

假設(shè)我們在http://www.mysite.com/下有些頁面調(diào)用一些GIF、jpg、png圖片,不允許別人盜鏈引用到他們自己的頁面上,因?yàn)檫@樣大大增加了服務(wù)器流量。
當(dāng)然我們不能100%保護(hù)圖片,但我們至少可以在得到瀏覽器發(fā)出的HTTP Referer header的地方限制這種情況,因?yàn)檫@個可以判斷是否我們自己的站點(diǎn)調(diào)用了我們自己的圖片。

[ISAPI_Rewrite]

RewriteCond Host: (.+)

RewriteCond Referer: (?!http://\1.*).*

RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]

相關(guān)文章

  • 安裝Apache和PHP的一些補(bǔ)充

    安裝Apache和PHP的一些補(bǔ)充

    PHP的安裝步驟,網(wǎng)上有很多資料,都非常詳細(xì)。但是,由于Apache,PHP這類自由軟件的安裝并不象商業(yè)軟件那樣有一個友好的用戶界面,許多網(wǎng)友又很少碰上這類東東,所以盡管旁邊有一份安裝資料,但還是碰上許多問題。我在國內(nèi)許多關(guān)于Linux和php的論壇上,也注意到了不少網(wǎng)友總問相似的問題。因此,我把我所知道的這類問題的解決方法寫出來,不對的地方,還請各位指出。
    2008-03-03
  • apache 配置文件解說

    apache 配置文件解說

    Apache為網(wǎng)絡(luò)管理員提供了豐富多彩的功能,包括目錄索引、目錄別名、內(nèi)容協(xié)商、可配置的HTTP錯誤報告、CGI程序的SetUID執(zhí)行、子進(jìn)程資源管理、服務(wù)器端圖象映射、重寫URL、URL拼寫檢查以及聯(lián)機(jī)手冊man等。也就是說,如果您在Linux Server上成功安裝配置了Apache之后,您的計算機(jī)也將隨著Apache的生效而搖身一變,成為一臺名副其實(shí)的Web Server,這種變化的確是激動人心的。
    2008-03-03
  • Windows下的PHP開啟DomXML

    Windows下的PHP開啟DomXML

    Windows下的PHP開啟DomXML...
    2007-01-01
  • 解決網(wǎng)頁打開是亂碼的問題

    解決網(wǎng)頁打開是亂碼的問題

    解決網(wǎng)頁打開是亂碼的問題...
    2007-02-02
  • 3389遠(yuǎn)程登錄怎么優(yōu)化才能解決藍(lán)屏或者黑屏問題

    3389遠(yuǎn)程登錄怎么優(yōu)化才能解決藍(lán)屏或者黑屏問題

    在遠(yuǎn)程登入時,出現(xiàn)藍(lán)屏或者是黑屏的問題,想必大家都有遇到過吧,在本文將為大家詳細(xì)介紹下如何優(yōu)化3389登錄解決此問題,感興趣的朋友不要錯過
    2013-10-10
  • 壓力測試工具Apache Bench實(shí)現(xiàn)原理及用法解析

    壓力測試工具Apache Bench實(shí)現(xiàn)原理及用法解析

    這篇文章主要介紹了壓力測試工具Apache Bench實(shí)現(xiàn)原理及用法解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-08-08
  • http www安全必備知識

    http www安全必備知識

    一、前言 還記得美國為首的北約轟炸我駐南聯(lián)盟使館,大家義憤填膺但又無可奈何,于是有黑客呼吁黑美國佬的網(wǎng)站,很快大家紛紛學(xué)習(xí)攻擊Web的方法和技巧,并且成功的黑了美國的幾個軍事主頁,有的還掛上了五星紅旗。這令美國政府十分尷尬。
    2008-03-03
  • 開發(fā)實(shí)例:JSP中實(shí)現(xiàn)全文檢索

    開發(fā)實(shí)例:JSP中實(shí)現(xiàn)全文檢索

    開發(fā)實(shí)例:JSP中實(shí)現(xiàn)全文檢索...
    2006-10-10
  • 遠(yuǎn)程鏡像與備份SVN服務(wù)器的方法小結(jié)

    遠(yuǎn)程鏡像與備份SVN服務(wù)器的方法小結(jié)

    此文講述SVN如何鏡像服務(wù)器,注意是單向鏡像。眾所周知,SVN有自已的鏡像命令svnsync(svn1.4以及以上版本特性),但是部署與維護(hù)確是繁瑣至極,令人望而卻步。
    2009-01-01
  • APACHE安裝筆記

    APACHE安裝筆記

    APACHE安裝筆記...
    2006-10-10

最新評論