{"id":254,"date":"2013-12-27T13:46:44","date_gmt":"2013-12-27T05:46:44","guid":{"rendered":"http:\/\/web.jofar.cn\/?p=254"},"modified":"2013-12-27T13:46:44","modified_gmt":"2013-12-27T05:46:44","slug":"isapi_rewrite3%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b%e4%ba%8c","status":"publish","type":"post","link":"https:\/\/web.jofar.cn\/?p=254","title":{"rendered":"ISAPI_Rewrite3\u4f7f\u7528\u6559\u7a0b(\u4e8c)"},"content":{"rendered":"<p>ISAPI_Rewrite3\u4f7f\u7528\u6559\u7a0b(\u4e8c)<\/p>\n<p><strong>\u63d2\u5165\u6210\u4efd<\/strong><br \/>\n\u63d2\u5165\u6210\u5206\u6709\u4e24\u4e2a\u7528\u5904\u2015\u2015\u628a\u9879\u76ee\u7f16\u7ec4\u5230\u5b50\u8868\u8fbe\u5f0f\u4e2d\uff0c\u5e76\u4e14\u5bf9\u751f\u6210\u7684\u5339\u914d\u6807\u53f7\u3002\u4f8b\u5982\uff0c\u8868\u8fbe\u5f0f&#8221;(ab)*&#8221;\u5c06\u5339\u914d\u6240\u6709\u7684\u8fd9\u7c7b\u5b57\u7b26\u4e32&#8221;ababab&#8221;\u3002\u6240\u6709\u7684\u88ab\u63d2\u5165\u6210\u4efd\u6807\u53f7\u7684\u5b50\u5339\u914d\u5c06\u53ef\u4ee5\u7528\\N\u6216\u8005$N\u8bed\u6cd5\u6765\u56de\u6eaf\u5f15\u7528\u5230\u3002\u5b83\u5141\u8bb8\u5b50\u8868\u8fbe\u5f0f\u5339\u914d\u7a7a\u5b57\u7b26\u4e32\uff0c\u5b50\u8868\u8fbe\u5f0f\u4ee51\u4e3a\u5f00\u59cb\u4ece\u5de6\u5f80\u53f3\u7f16\u53f7\u3002\u5b50\u8868\u8fbe\u5f0f0\u5c31\u662f\u6574\u4e2a\u8868\u8fbe\u5f0f\u3002<\/p>\n<p><strong>\u6b63\u5219\u8868\u8fbe\u5f0f<\/strong><\/p>\n<p><strong>\u65e0\u6807\u8bb0\u63d2\u5165<\/strong><\/p>\n<p>\u6709\u65f6\u5019\u4f60\u9700\u8981\u628a\u5b50\u8868\u8fbe\u5f0f\u7f16\u7ec4\u4e3a\u63d2\u5165\u6210\u4efd\uff0c\u4f46\u662f\u4e0d\u60f3\u4e3a\u8fd9\u4e2a\u63d2\u5165\u6210\u5206\u800c\u5410\u51fa\u53e6\u4e00\u4e2a\u6807\u8bb0\u7684\u5b50\u8868\u8fbe\u5f0f\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u975e\u6807\u8bb0\u63d2\u5165(?:expression)\u53ef\u80fd\u6709\u7528\u3002<br \/>\n\u4f8b\u5982\uff0c\u4e0b\u4f8b\u8868\u8fbe\u5f0f\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u975e\u5b50\u8868\u8fbe\u5f0f\uff1a<br \/>\n&#8220;(?:abc)*&#8221;<\/p>\n<p><strong>N\u62e91\u6807\u8bb0<\/strong><br \/>\n\u5f53\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5339\u914d\u4e00\u4e2a\u5b50\u8868\u8fbe\u5f0f\u6216\u53e6\u4e00\u4e2a\u7684\u65f6\u5019\uff0cN\u62e91\u6807\u8bb0\u8d77\u4f5c\u7528\u4e86\u3002\u6bcf\u4e2aN\u62e91\u53ef\u4ee5\u7528|\u9694\u5f00\u3002\u6bcf\u4e2aN\u62e91\u6807\u8bb0\u662f\u4e00\u4e2a\u6700\u5927\u53ef\u80fd\u6027\u524d\u7f00\u5b50\u8868\u8fbe\u5f0f\uff0c\u5b83\u662f\u548c\u91cd\u590d\u64cd\u4f5c\u7b26\u76f8\u53cd\u7684\u884c\u4e3a\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\n&#8220;a(b|c)&#8221;\u5339\u914d&#8221;ab&#8221;\u6216&#8221;ac&#8221;<br \/>\n&#8220;abc|def&#8221;\u5339\u914d&#8221;abc&#8221;\u6216&#8221;def&#8221;<\/p>\n<p><strong>\u9884\u7f6e\u7b26<br \/>\n<\/strong>\u4e00\u4e2a\u9884\u7f6e\u7b26\u662f\u4e00\u4e2a\u53ef\u4ee5\u5339\u914d\u6240\u6709\u4f5c\u4e3a\u9884\u7f6e\u6210\u5458\u7684\u5355\u4e2a\u5b57\u7b26\u7684\u9884\u7f6e\u3002\u9884\u7f6e\u5b57\u7b26\u7528\u65b9\u62ec\u53f7\u201c[\u201d\u548c\u201c]\u201d\u62ec\u8d77\u6765\uff0c\u53ef\u4ee5\u5bb9\u7eb3\u5b57\u9762\u503c\u3001\u5b57\u7b26\u5e8f\u5217\u3001\u5b57\u7b26\u7c7b\u3001\u7ecf\u6574\u7406\u8fc7\u7684\u5bf9\u8c61\u4ee5\u53ca\u7b49\u4ef7\u7684\u7c7b\u3002\u7528^\u6253\u5934\u7684\u9884\u7f6e\u58f0\u660e\u53ef\u4ee5\u6392\u9664\u5305\u542b\u7684\u5185\u5bb9\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\n\u5b57\u9762\u503c<br \/>\n&#8220;[abc]&#8221;\u5339\u914d&#8221;a&#8221;\u6216&#8221;b&#8221;\u6216&#8221;b&#8221;\u3002<br \/>\n&#8220;[^abc]&#8221;\u5339\u914d&#8221;a&#8221;\u548c&#8221;b&#8221;\u548c&#8221;c&#8221;\u4e4b\u5916\u7684\u6240\u6709\u5b57\u7b26\u3002<\/p>\n<p><strong>\u5b57\u7b26\u5e8f\u5217<\/strong><br \/>\n&#8220;[a-z]&#8221;\u5339\u914d\u6240\u6709\u7684\u4ece&#8221;a&#8221;\u5230&#8221;z&#8221;\u7684\u5b57\u7b26<br \/>\n&#8220;[^A-Z]&#8221;\u5339\u914d\u6240\u6709\u7684\u5b57\u7b26\u9664\u4e86\u4ece&#8221;A&#8221;\u5230&#8221;Z&#8221;\u7684\u8fd9\u4e9b\u5b57\u7b26\u3002<\/p>\n<p><strong>\u5b57\u7b26\u7c7b<\/strong><br \/>\n\u5b57\u7b26\u7c7b\u7528\u8bed\u6cd5&#8221;[:classname:]&#8221;\u6765\u8868\u793a\uff0cclassname\u662f\u58f0\u660e\u8fc7\u7684\u9884\u8bbe\u503c\u4e2d\u7684\u4e00\u4e2a\u3002\u4f8b\u5982\uff1a&#8221;[[:space:]]&#8221;\u662f\u6240\u6709\u7684\u7a7a\u767d\u5360\u4f4d\u7b26\u7684\u9884\u8bbe\u3002\u4e0b\u8868\u4e2d\u7684\u5b57\u7b26\u7c7b\u662f\u53ef\u7528\u7684\uff1a<\/p>\n<table>\n<tbody>\n<tr>\n<td>alnum<\/td>\n<td>\u6240\u6709\u7684alpha\u6570\u5b57\u5b57\u6bcd<\/td>\n<\/tr>\n<tr>\n<td>alpha<\/td>\n<td>\u5b57\u6bcd\u8868\u5b57\u7b26[a-zA-Z]\u3002\u5176\u5b83\u5b57\u7b26\u4e5f\u53ef\u4ee5\u5305\u542b\u5728\u5185\uff0c\u8fd9\u53d6\u51b3\u4e8e\u672c\u5730\u73af\u5883<\/td>\n<\/tr>\n<tr>\n<td>blank<\/td>\n<td>\u6240\u6709\u7684\u7a7a\u767d\u5b57\u7b26\uff0c\u5305\u542b\u56de\u8f66\u6216\u8005\u7a7a\u683c<\/td>\n<\/tr>\n<tr>\n<td>cntrl<\/td>\n<td>\u6240\u6709\u7684\u63a7\u5236\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>digit<\/td>\n<td>\u4ece0\u52309\u7684\u6570\u5b57<\/td>\n<\/tr>\n<tr>\n<td>graph<\/td>\n<td>\u6240\u6709\u7684\u56fe\u753b\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>lower<\/td>\n<td>\u6240\u6709\u7684\u5c0f\u5199\u5b57\u6bcd[a-z]\uff0c\u5176\u5b83\u7684\u5b57\u7b26\u4e5f\u53ef\u4ee5\u5305\u542b\u5728\u5185\uff0c\u8fd9\u53d6\u51b3\u4e8e\u672c\u5730\u73af\u5883<\/td>\n<\/tr>\n<tr>\n<td>print<\/td>\n<td>\u6240\u6709\u7684\u5370\u5237\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>punct<\/td>\n<td>\u6240\u6709\u7684\u6807\u70b9\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td>space<\/td>\n<td>\u6240\u6709\u7684\u7a7a\u767d\u5360\u4f4d\u7b26<\/td>\n<\/tr>\n<tr>\n<td>upper<\/td>\n<td>\u6240\u6709\u7684\u5927\u5199\u5b57\u6bcd[A-Z]\uff0c\u5176\u5b83\u7684\u5b57\u7b26\u4e5f\u53ef\u4ee5\u5305\u542b\u5728\u5185\uff0c\u8fd9\u53d6\u51b3\u4e8e\u672c\u5730\u73af\u5883<\/td>\n<\/tr>\n<tr>\n<td>xdigit<\/td>\n<td>\u6240\u6709\u768416\u8fdb\u5b57\u5b57\u7b260~9\uff0cA-F<\/td>\n<\/tr>\n<tr>\n<td>word<\/td>\n<td>\u6240\u6709\u7684\u8bcd\u6c47\u5b57\u7b26\uff0c\u5305\u62ec\u5b57\u6bcd\u6570\u5b57\u5916\u52a0underscore<\/td>\n<\/tr>\n<tr>\n<td>unicode<\/td>\n<td>\u6240\u6709\u7684\u7f16\u7801\u5927\u4e8e255\u7684\u5b57\u7b26\uff0c\u8fd9\u53ea\u5bf9\u5927\u8303\u56f4\u5b57\u7b26\u7279\u5f81\u7c7b\u751f\u6548<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u91cc\u6709\u4e00\u4e9b\u7f29\u5199\u6cd5\u53ef\u4ee5\u4ee3\u66ff\u4ee5\u4e0a\u5b57\u7b26\u7c7b\uff1a<br \/>\n\\w \u4ee3\u66ff [:word:]<br \/>\n\\s \u4ee3\u66ff [:space:]<br \/>\n\\d \u4ee3\u66ff [:digit:]<br \/>\n\\l \u4ee3\u66ff [:lower:]<br \/>\n\\u \u4ee3\u66ff [:upper:]<\/p>\n<p>&nbsp;<\/p>\n<h3>\u6b63\u5219\u8868\u8fbe\u5f0f<\/h3>\n<p>\u96c6\u5408\u5143\u7d20<br \/>\n\u96c6\u5408\u5143\u7d20\u4e00\u822c\u91c7\u7528\u9884\u7f6e\u58f0\u660e\u5185\u52a0[.tagname.]\u7684\u683c\u5f0f\u3002\u5176\u4e2dtagname\u65e2\u53ef\u4ee5\u662f\u4e00\u4e2a\u5355\u4e2a\u5b57\u7b26\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u96c6\u5408\u5143\u7d20\u540d\u3002\u4f8b\u5982\uff1a[[.a.]]\u7b49\u4ef7\u4e8e[a]\uff0c[[.comma.]]\u7b49\u4ef7\u4e8e[,]\u3002ISAPI_Rewrite\u652f\u6301\u6240\u6709\u7684\u6807\u51c6POSIX\u96c6\u5408\u5143\u7d20\u540d\uff0c\u4ee5\u53ca\u4e0b\u9762\u7684\u8fd9\u4e9b\u5b57\u7b26\u7ec4\u5408\uff1a\u201cae\u201d\u3001\u201cch\u201d\u3001\u201cll\u201d\u3001\u201css\u201d\u3001\u201cnj\u201d\u3001\u201cdz\u201d\u3001\u201clj\u201d\u3001\u4efb\u610f\u5c0f\u5199\u3001\u5927\u5199\u3001\u9996\u5b57\u6bcd\u5927\u5199\u7684\u53d8\u5316\u7ec4\u5408\u3002\u591a\u4e2a\u5b57\u7b26\u96c6\u5408\u5143\u7d20\u53ef\u4ee5\u5bfc\u81f4\u9884\u7f6e\u5339\u914d\u4e00\u4e2a\u4ee5\u4e0a\u7684\u5b57\u7b26\u3002\u4f8b\u5982\uff1a[[.ae.]]\u5c06\u5339\u914d\u4e24\u4e2a\u5b57\u7b26\uff0c\u4f46\u662f[^[.ae.]]\u53ea\u4f1a\u5339\u914d\u4e00\u4e2a\u5b57\u7b26\u3002<br \/>\n<strong>\u7b49\u4ef7\u7c7b<\/strong><br \/>\n\u7b49\u4ef7\u7c7b\u4e00\u822c\u91c7\u7528\u9884\u7f6e\u58f0\u660e\u5185\u52a0[=tagname=]\u7684\u683c\u5f0f\uff0c\u5176\u4e2dtagname\u65e2\u53ef\u4ee5\u662f\u5355\u4e2a\u5b57\u7b26\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u96c6\u5408\u5143\u7d20\u7684\u540d\u79f0\uff0c\u5b83\u80fd\u5339\u914d\u540c\u6837\u7684\u4e3b\u8981\u7b49\u4ef7\u7c7b\u6210\u5458\u7684\u5b57\u7b26\uff0c\u5c31\u8ddf\u96c6\u5408\u5143\u7d20[.tagname.]\u4e00\u6837\u3002\u4e00\u4e2a\u7b49\u7ea7\u7c7b\u662f\u4e00\u4e2a\u76f8\u540c\u6574\u7406\u7684\u5b57\u7b26\u9884\u8bbe\uff0c\u4f46\u4e3b\u8981\u662f\u4e00\u4e2a\u7b49\u4ef7\u7c7b\u7684\u5b57\u7b26\u96c6\uff0c\u5176\u4e3b\u8981\u6392\u5e8f\u5173\u952e\u5b57\u90fd\u662f\u4e00\u6837\u7684\uff08\u4f8b\u5982\uff0c\u5b57\u7b26\u4e32\u901a\u5e38\u5148\u4f9d\u5b57\u7b26\u6574\u7406\uff0c\u7136\u540e\u6839\u636e\u91cd\u97f3\uff0c\u7136\u540e\u6839\u636e\u5927\u5c0f\u5199\u3002\u4e3b\u8981\u6392\u5e8f\u952e\u4e0e\u5b57\u7b26\u76f8\u5173\uff0c\u6b21\u8981\u4e0e\u91cd\u97f3\u76f8\u5173\uff0c\u518d\u6b21\u4e0e\u5927\u5c0f\u5199\u76f8\u5173\u3002\u5982\u679c\u6ca1\u6709\u7b49\u4ef7\u7c7b\u7b26\u5408tagname\uff0c\u5219[=tagname=]\u662f\u4e0e[.tagname.]\u5b8c\u5168\u4e00\u6837\u7684\u3002<br \/>\nEquivalence classes take the general form [=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.].<br \/>\n\u8981\u5728\u4e00\u4e2a\u9884\u8bbe\u4e2d\u5305\u542b\u5b57\u9762\u503c\u201c-\u201d\uff0c\u8bf7\u8fd9\u6837\u505a\uff1a\u4f7f\u5b83\u6210\u4e3a\u5f00\u653e\u7684\u201c[\u201d\u6216\u8005\u201c[^\u201d\u540e\u9762\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u3001\u4e00\u4e2a\u7cfb\u5217\u6216\u8005\u4e00\u4e2a\u96c6\u5408\u5143\u7d20\u7684\u672b\u70b9\uff0c\u6216\u8005\u7528\u4e00\u4e2a\u524d\u7f6e\u7684\u8f6c\u4e49\u5b57\u7b26\u5982\u201c[\\-]\u201d\u3002\u8981\u5728\u4e00\u4e2a\u9884\u8bbe\u4e2d\u5305\u542b\u4e00\u4e2a\u5b57\u9762\u503c\u201c[\u201d\u6216\u8005\u201c]\u201d\u6216\u8005\u201c^\u201d\uff0c\u8bf7\u628a\u5b83\u4eec\u4f5c\u4e3a\u4e00\u4e2a\u7cfb\u5217\u6216\u8005\u4e00\u4e2a\u96c6\u5408\u5143\u7d20\u7684\u672b\u70b9\uff0c\u6216\u8005\u7528\u4e00\u4e2a\u524d\u7f6e\u7684\u8f6c\u4e49\u5b57\u7b26\u3002<br \/>\n<strong>\u884c\u951a<\/strong><br \/>\n\u951a\u7528\u6765\u5339\u914d\u4e00\u884c\u5f00\u5934\u6216\u7ed3\u5c3e\u7684\u7a7a\u4e32\u3002\u201c^\u201d\u5339\u914d\u884c\u5f00\u5934\u7684\u7a7a\u4e32\uff0c\u201c$\u201d\u5339\u914d\u884c\u7ed3\u5c3e\u7684\u7a7a\u4e32\u3002<br \/>\n<strong>\u56de\u6eaf\u5f15\u7528<\/strong><br \/>\n\u56de\u6eaf\u5f15\u7528\u662f\u5f15\u7528\u524d\u9762\u5df2\u7ecf\u88ab\u5339\u914d\u7684\u5b50\u8868\u8fbe\u5f0f\u3002\u8fd9\u4e2a\u5f15\u7528\u662f\u88ab\u5339\u914d\u7684\u5b50\u8868\u8fbe\u5f0f\uff0c\u800c\u4e0d\u662f\u8868\u8fbe\u5f0f\u672c\u8eab\u3002\u56de\u6eaf\u5f15\u7528\u5305\u62ec\u8f6c\u4e49\u5b57\u7b26\u201c\\\u201d\u8ddf\u7740\u4e00\u4e2a\u4ece1\u52309\u7684\u6570\u5b57\u3002\u201c\\1\u201d\u5f15\u7528\u7b2c\u4e00\u4e2a\u5b50\u8868\u8fbe\u5f0f\uff0c\u201c\\2\u201d\u5f15\u7528\u7b2c\u4e8c\u4e2a\uff0c\u4f9d\u6b21\u7c7b\u63a8\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u8868\u8fbe\u5f0f\u201c(.*)\\1\u201d\u5339\u914d\u4efb\u4f55\u5173\u4e8e\u5b83\u7684\u4e2d\u70b9\u91cd\u590d\u7684\u5b57\u7b26\u4e32\uff0c\u6bd4\u5982\u8bf4\u201cabcabc\u201d\u6216\u8005\u201cxyzxyz\u201d\u3002\u4e00\u4e2a\u5bf9\u5b50\u8868\u8fbe\u5f0f\u7684\u56de\u6eaf\u5f15\u7528\u4e0d\u53c2\u52a0\u4efb\u4f55\u5339\u914d\uff0c\u5339\u914d\u7a7a\u5b57\u7b26\u4e32\u3002\u5728ISAPI_Rewrite\u4e2d\uff0c\u6240\u6709\u7684\u56de\u6eaf\u5f15\u7528\u662f\u5bf9\u6574\u4e2aRewriteRule\u548c\u76f8\u5e94\u7684RewriteCond\u6307\u4ee4\u662f\u5168\u5c40\u6027\u76f8\u5173\u7684\u3002RewriteRule\u6307\u4ee4\u4e2d\u5982\u679c\u6709RewirteCond\u5b50\u4ee4\u7684\u8bdd\uff0c\u5b50\u5339\u914d\u4ece\u76f8\u5e94\u7684RewriteRule\u6307\u4ee4\u7684\u7b2c\u4e00\u4e2aRewriteCond\u6307\u4ee4\u5f00\u59cb\u4ece\u4e0a\u5230\u4e0b\u4ece\u5de6\u5f80\u53f3\u7f16\u53f7\u3002<br \/>\n<strong>\u5411\u524d\u67e5\u627e<\/strong><br \/>\n\u5411\u524d\u67e5\u627e\u6709\u4e24\u79cd\u5f62\u5f0f\uff1a\u6b63\u5411\u524d\u67e5\u627e\u548c\u8d1f\u5411\u524d\u67e5\u627e\u3002<br \/>\n? &#8220;(?=abc)&#8221;\u5339\u914d\u8ddf\u5728\u8868\u8fbe\u5f0f&#8221;abc&#8221;\u540e\u9762\u7684\u96f6\u5b57\u7b26\u3002<br \/>\n? &#8220;(?!abc)&#8221;\u5339\u914d\u4e0d\u8ddf\u5728\u8868\u8fbe\u5f0f&#8221;abc&#8221;\u540e\u9762\u7684\u96f6\u5b57\u7b26\u3002<br \/>\n<strong>\u901a\u914d\u7b26<\/strong><br \/>\n\u4e0b\u9762\u7684\u8fd0\u7b97\u7b26\u63d0\u4f9b\u4e86\u4e0eGNU\u6b63\u5219\u8868\u8fbe\u5f0f\u5e93\u7684\u517c\u5bb9\u6027\u3002<br \/>\n? &#8220;\\w&#8221;\u5339\u914d\u4efb\u610f\u5355\u4e2a\u7ec4\u8bcd\u5b57\u7b26\uff0c\u5b83\u7b49\u4ef7\u4e8e\u8868\u8fbe\u5f0f\u201c[[:word:]]\u201d\u3002<br \/>\n? &#8220;\\W&#8221;\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u975e\u7ec4\u8bcd\u5b57\u7b26\uff0c\u5b83\u7b49\u4ef7\u4e8e\u8868\u8fbe\u5f0f\u201c[^[:word:]]\u201d\u3002<br \/>\n? &#8220;\\&lt;&#8220;\u5339\u914d\u8bcd\u5934\u7a7a\u5b57\u7b26\u4e32\u3002<br \/>\n? &#8220;\\&gt;&#8221;\u5339\u914d\u8bcd\u5c3e\u7a7a\u5b57\u7b26\u4e32\u3002<br \/>\n? &#8220;\\b&#8221;\u5339\u914d\u8bcd\u5934\u6216\u8005\u8bcd\u5c3e\u7a7a\u5b57\u7b26\u4e32\u3002<br \/>\n? &#8220;\\B&#8221;\u5339\u914d\u8bcd\u8bed\u4e2d\u7684\u7a7a\u5b57\u7b26\u4e32\u3002<br \/>\n<strong>\u8f6c\u4e49\u5b57\u7b26<\/strong><br \/>\n\u8f6c\u4e49\u5b57\u7b26\u201c\\\u201d\u542b\u6709\u591a\u91cd\u610f\u4e49\uff1a<br \/>\n? \u8f6c\u4e49\u5b57\u7b26\u53ef\u4ee5\u5f15\u5bfc\u4e00\u4e2a\u8fd0\u7b97\u7b26\uff0c\u4f8b\u5982\uff1a\u56de\u6eaf\u5f15\u7528\u3001\u8bcd\u64cd\u4f5c\u7b26<br \/>\n? \u8f6c\u4e49\u5b57\u7b26\u53ef\u4ee5\u4f7f\u4e0b\u9762\u7684\u5b57\u7b26\u6b63\u5e38\uff0c\u6bd4\u5982\u8bf4\u201c\\*\u201d\u4ee3\u8868\u4e00\u4e2a\u5b57\u9762\u503c\u201c*\u201d\uff0c\u800c\u4e0d\u662f\u91cd\u590d\u8fd0\u7b97\u7b26\u3002<\/p>\n<p><strong>\u5355\u4e2a\u5b57\u7b26\u8f6c\u4e49\u5e8f\u5217<\/strong><br \/>\n\u4e0b\u9762\u7684\u8f6c\u4e49\u5e8f\u5217\u662f\u5355\u4e2a\u5b57\u7b26\u7684\u522b\u540d\uff1a<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8f6c\u4e49\u5e8f\u5217<\/td>\n<td>\u5b57\u7b26\u4ee3\u7801<\/td>\n<td>\u542b\u4e49<\/td>\n<\/tr>\n<tr>\n<td>\\a<\/td>\n<td>0x07<\/td>\n<td>\u4fe1\u53f7\u94c3\u8bb0\u53f7.<\/td>\n<\/tr>\n<tr>\n<td>\\t<\/td>\n<td>0x09<\/td>\n<td>\u5236\u8868\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\v<\/td>\n<td>0x0B<\/td>\n<td>\u5782\u76f4\u5236\u8868\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\e<\/td>\n<td>0x1B<\/td>\n<td>ASCII\u8f6c\u4e49\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\0dd<\/td>\n<td>0dd<\/td>\n<td>\u516b\u8fdb\u5236\u5b57\u7b26\u4ee3\u7801\uff0c\u5176\u4e2ddd\u662f\u4e00\u4e2a\u6216\u591a\u4e2a\u516b\u8fdb\u5236\u6570\u5b57\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\xXX<\/td>\n<td>0xXX<\/td>\n<td>\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4ee3\u7801\uff0c\u5176\u4e2dXX\u662f\u4e00\u4e2a\u6216\u591a\u4e2a\u516b\u8fdb\u5236\u6570\u5b57\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\x{XX}<\/td>\n<td>0xXX<\/td>\n<td>\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4ee3\u7801\uff0c\u5176\u4e2dXX\u662f\u4e00\u4e2a\u6216\u66f4\u591a\u5341\u516d\u8fdb\u5236\u6570\u5b57\uff0c\u53ef\u9009\u7528Unicode\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\cZ<\/td>\n<td>z-@<\/td>\n<td>ASCII\u8f6c\u4e49\u5e8f\u5217control-Z\uff0c\u5176\u4e2dZ\u662f\u4efb\u610f\u4e00\u4e2a\u7f16\u7801\u5927\u4e8e\u6216\u7b49\u4e8e\u201c@\u201d\u7684\u7f16\u7801\u7684ASCII\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u6742\u9879\u8f6c\u4e49\u5e8f\u5217<\/strong><br \/>\n\u4ee5\u4e0b\u63d0\u4f9bperl\u7684\u5927\u90e8\u5206\u517c\u5bb9\u6027\uff0c\u4f46\u662f\u5728\\l\u3001\\L\u3001\\u\u548c\\U\u4e0a\u6709\u4e00\u4e9b\u533a\u522b<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8f6c\u4e49\u5e8f\u5217<\/td>\n<td>\u542b\u4e49<\/td>\n<\/tr>\n<tr>\n<td>\\w<\/td>\n<td>\u7b49\u4ef7\u4e8e [[:word:]].<\/td>\n<\/tr>\n<tr>\n<td>\\W<\/td>\n<td>\u7b49\u4ef7\u4e8e[^[:word:]].<\/td>\n<\/tr>\n<tr>\n<td>\\s<\/td>\n<td>\u7b49\u4ef7\u4e8e[[:space:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\S<\/td>\n<td>\u7b49\u4ef7\u4e8e[^[:space:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\d<\/td>\n<td>\u7b49\u4ef7\u4e8e[[:digit:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\D<\/td>\n<td>\u7b49\u4ef7\u4e8e[^[:digit:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\l<\/td>\n<td>\u7b49\u4ef7\u4e8e[[:lower:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\L<\/td>\n<td>\u7b49\u4ef7\u4e8e[^[:lower:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\u<\/td>\n<td>\u7b49\u4ef7\u4e8e[[:upper:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\U<\/td>\n<td>\u7b49\u4ef7\u4e8e[^[:upper:]]\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\C<\/td>\n<td>\u4efb\u4f55\u5355\u4e2a\u5b57\u7b26\uff0c\u7b49\u4ef7\u4e8e\u201c.\u201d<\/td>\n<\/tr>\n<tr>\n<td>\\X<\/td>\n<td>\u5339\u914d\u4efb\u4f55Unicode\u7ec4\u5408\u5b57\u7b26\u5e8f\u5217\uff0c\u4f8b\u5982\u201ca\\x0301\u201d(\u5b57\u7b26a\u548c\u4e00\u4e2a\u5c16\u89d2)<\/td>\n<\/tr>\n<tr>\n<td>\\Q<\/td>\n<td>\u5f00\u59cb\u5f15\u53f7\u8fd0\u7b97\u7b26\u3002\u540e\u9762\u8ddf\u524d\u7684\u6240\u6709\u7684\u5185\u5bb9\u90fd\u88ab\u5f53\u4f5c\u5b57\u9762\u503c\uff0c\u76f4\u5230\u53d1\u73b0\u4e00\u4e2a\\E\u7ed3\u675f\u8fd0\u7b97\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\E<\/td>\n<td>\u7ed3\u675f\u5f15\u7528\u8fd0\u7b97\u7b26\uff0c\u7ec8\u6b62\u4e00\u4e2a\u7531\\Q\u5f00\u5934\u7684\u5f15\u7528\u5e8f\u5217\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u600e\u6837\u5f97\u5230\u5339\u914d<\/strong><br \/>\n\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u5339\u914d\u7b2c\u4e00\u4e2a\u53ef\u5339\u914d\u5b57\u7b26\u4e32\u3002\u5982\u679c\u4ece\u7ed9\u5b9a\u7684\u8d77\u59cb\u5904\u53ef\u4ee5\u5339\u914d\u5230\u4e0d\u6b62\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5219\u5b83\u4f1a\u5339\u914d\u90a3\u4e2a\u80fd\u5339\u914d\u5f97\u6700\u957f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u4ece\u540c\u4e00\u4e2a\u8d77\u59cb\u5904\u6709\u591a\u4e2a\u5408\u9002\u7684\u5339\u914d\uff0c\u800c\u4e14\u6bcf\u4e2a\u5339\u914d\u7684\u957f\u5ea6\u90fd\u4e00\u6837\uff0c\u5219\u5c06\u9009\u62e9\u90a3\u4e2a\u7b2c\u4e00\u5b50\u8868\u8fbe\u5f0f\u5339\u914d\u5f97\u6700\u957f\u7684\u5339\u914d\u3002\u5982\u679c\u6709\u4e24\u4e2a\u4ee5\u4e0a\u7684\u5339\u914d\u5b57\u7b26\u4e32\u5b83\u4eec\u7684\u7b2c\u4e00\u5b50\u8868\u8fbe\u5f0f\u5339\u914d\u5f97\u4e00\u6837\u957f\uff0c\u5219\u6bd4\u8f83\u7b2c\u4e8c\u5b50\u8868\u8fbe\u5f0f\u5339\u914d\u7684\u957f\u5ea6\uff0c\u5982\u6b64\u7c7b\u63a8\u3002\u6ce8\u610f\uff1aISAPI_Rewrite\u4f7f\u7528\u6bd4\u5c01\u6f14\u7b97\u6cd5\u3002\u53ea\u6709\u8868\u8fbe\u5f0f\u5339\u914d\u4e86\u6574\u4e2a\u987a\u5e8f\u4e32\u624d\u80fd\u5f97\u5230\u5339\u914d\u7ed3\u679c\u3002\u4f8b\u5982\uff1a<br \/>\n? RewriteCond URL ^\/somedir\/.* #\u5c06\u5339\u914d\u4efb\u4f55\u5bfc\u5411somedir\u76ee\u5f55\u4ee5\u53ca\u5b83\u7684\u5b50\u76ee\u5f55\u7684\u8bf7\u6c42\uff0c\u4e0e\u6b64\u540c\u65f6\uff0c<br \/>\n? RewriteCond URL ^\/somedir\/ #\u53ea\u5339\u914dsomedir\u6839\u76ee\u5f55\u7684\u8bf7\u6c42\u3002<br \/>\n<strong>\u5bf9\u201c\u75c5\u6001\u201d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7279\u522b\u63d0\u793a\uff1a<\/strong><br \/>\nISAPI_Rewrite \u4f7f\u7528\u4e86\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u6765\u81eaBoost\u5e93\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5f15\u64ce\u3002\u4f46\u662f\u5b83\u4f9d\u7136\u6709\u4e00\u4e9b\u5c40\u9650\u6027\uff1a\u6709\u7740\u4e00\u4e9b\u201c\u75c5\u6001\u201d\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u53ef\u80fd\u4f1a\u6307\u6570\u7ea7\u5730\u6d88\u8017\u5339\u914d\u65f6\u95f4\u3002\u8fd9\u4e9b\u90fd\u6d89\u53ca\u5230\u5d4c\u5957\u91cd\u590d\u8fd0\u7b97\u7b26\uff0c\u4f8b\u5982\u8bd5\u56fe\u5bf9N\u4e2a\u8fde\u7eed\u5b57\u6bcda\u5339\u914d\u8868\u8fbe\u5f0f\u201c(a*a)*b\u201d\uff0c\u6d88\u8017\u7684\u65f6\u95f4\u5c06\u4e0eN<sup>2<\/sup>\u6210\u6b63\u6bd4\u3002\u8fd9\u4e9b\u8868\u8fbe\u5f0f\u5e38\u5e38\u80fd\u6539\u6210\u53e6\u4e00\u79cd\u5199\u6cd5\u6765\u907f\u514d\u8fd9\u79cd\u95ee\u9898\u3002\u4f8b\u5982\uff0c\u201c(a*a)*b\u201d\u53ef\u4ee5\u88ab\u6539\u5199\u6210\u201ca*b\u201d\uff0c\u89e3\u6790\u5b83\u6d88\u8017\u7684\u65f6\u95f4\u4e0eN\u6210\u6b63\u6bd4\u3002\u5728\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u975e\u5d4c\u5957\u91cd\u590d\u8868\u8fbe\u5f0f\u6d88\u8017\u7684\u65f6\u95f4\u4e0eN<sup>2<\/sup>\u6210\u6b63\u6bd4\uff0c\u4f46\u662f\uff0c\u5982\u679c\u6761\u6b3e\u662f\u76f8\u4e92\u6392\u65a5\u7684\uff0c\u5219\u5b83\u4eec\u4f1a\u5728\u7ebf\u6027\u65f6\u95f4\u91cc\u5b8c\u6210\u5339\u914d\u3002\u5728\u201ca*b\u201d\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u5b57\u7b26\u5c06\u8981\u4e48\u5339\u914da\u8981\u4e48\u5339\u914db\u6216\u8005\u4e0d\u5339\u914d\u3002\u76f8\u8f83\u4e4b\u4e0b\uff0c\u201ca*a\u201d\u5339\u914d\u5668\u4e0d\u80fd\u544a\u77e5\u54ea\u4e2a\u5206\u652f\u88ab\u91c7\u53d6\uff08\u7b2c\u4e00\u4e2a a\u8fd8\u662f\u7b2c\u4e8c\u4e2aa\uff09\u56e0\u6b64\u5fc5\u987b\u5c1d\u8bd5\u4e24\u79cd\u3002<br \/>\nRegex\u53ef\u4ee5\u68c0\u6d4b\u51fa\u8fd9\u79cd\u201c\u75c5\u6001\u201d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5e76\u7ec8\u6b62\u548c\u5b83\u4eec\u7684\u5339\u914d\u3002\u8fd9\u5c06\u4f7fISAPI_Rewrite\u7684\u89c4\u5219\u5931\u6548\u3002\u5f53\u4e00\u4e2a\u89c4\u5219\u5931\u6548\u65f6\uff0cISAPI_Rewrite\u5c06\u7ed9\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2a&#8221;Internal Server error &#8211; Rule Failed&#8221;\u7684\u72b6\u6001\uff0c\u4ee5\u8868\u793a\u914d\u7f6e\u9519\u8bef\u3002<\/p>\n<p><strong>4.1AccessFileName\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u8bbe\u7f6e\u5206\u5e03\u5f0f\u914d\u7f6e\u6587\u4ef6\u7684\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td><em>AccessFileName filename<\/em>?[filename] &#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td><em>AccessFileName .htaccess<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6307\u5b9a\u4e00\u4e2aISAPI_ReWrite\u5bfb\u6c42\u5206\u5e03\u5f0f\u914d\u7f6e\u7684\u6587\u4ef6\u540d\u5217\u8868\u3002\u9ed8\u8ba4\u6587\u4ef6\u540d\u662f.htaccess\u3002ISAPI_ReWrite\u53ea\u80fd\u8f7d\u5165\u5b83\u80fd\u5728\u8fd9\u4e2a\u5217\u8868\u4e2d\u627e\u5230\u7684\u7b2c\u4e00\u4e2a\u6587\u4ef6\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0bISAPI_ReWrite\u7ba1\u7406\u8005\u4f1a\u4ee5<em>hidden<\/em>\u5c5e\u6027\u6807\u8bb0\u914d\u7f6e\u6587\u4ef6-\u5b83\u5c06\u9632\u6b62\u6587\u4ef6\u88ab\u8fdc\u7a0b\u7528\u6237\u76f4\u63a5\u8bbf\u95ee\u5230\u3002<br \/>\n\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u4e86\u4efb\u4f55\u4fee\u6539\uff0c\u5b83\u5c06\u5728\u4e0b\u6b21\u8bf7\u6c42\u670d\u52a1\u5668\u65f6\u81ea\u52a8\u52a0\u8f7d\u3002<\/p>\n<p><strong>4.2 ? ? ? AllowOverride\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u660e\u786e\u89c4\u5b9a\u4e86\u6bcf\u4e2a\u76ee\u5f55\u91cd\u5199\u7684\u57fa\u51c6URL\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td><em>AllowOverride Al<\/em>l|<em>None<\/em>|<em>directive-type [directive-type] ..<\/em>.<\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td><em>AllowOverride All<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u58f0\u660e\u4e86\u5728\u5206\u5e03\u5f0f.htaccess\u6587\u4ef6\u91cc\u7684\u6307\u4ee4\u662f\u5426\u53ef\u4ee5\u8986\u76d6\u7236\u7ea7\u522b\u7684httpd.conf\u4e2d\u7684\u6307\u4ee4\u3002\u5728ISAPI_Rewrite\u7684\u4f7f\u7528\u73af\u5883\u4e2d\uff0c\u8fd9\u4e2a\u6307\u4ee4\u5b9e\u9645\u4e0a\u63a7\u5236\u4e86\u7279\u5b9a\u865a\u62df\u4e3b\u673a\u6216\u8005\u76ee\u5f55\u7684.htaccess\u6587\u4ef6\u7684\u53ef\u7528\u6216\u8005\u4e0d\u53ef\u7528\u3002<br \/>\n\u76ee\u524d\u53ea\u652f\u6301\u4e09\u4e2a\u503c\uff1a<strong>All<\/strong>\u3001<strong>None<\/strong>\u548c<strong>FileInfo<\/strong>\u3002<br \/>\n<strong>All<\/strong>\u548c<strong>FileInfo<\/strong>\u4f7f.htaccess\u6587\u4ef6\u4ee5\u53ca\u5b83\u91cc\u9762\u7684\u6574\u4e2aISAPI_Rewrite\u76ee\u5f55\u53ef\u7528\uff0c<strong>None<\/strong>\u4f7f\u6240\u6709\u7684.htaccess\u6587\u4ef6\u4ee5\u53ca\u76ee\u5f55\u4e0d\u53ef\u7528\u3002\u8fd9\u4e9b\u76ee\u5f55\u5177\u6709\u7ee7\u627f\u6027\u3002\u8fd9\u610f\u5473\u7740\u5982\u679c\u4f60\u4e3a\u4e00\u4e9b\u76ee\u5f55\u6216\u8005\u865a\u62df\u4e3b\u673a\u6307\u5b9a<em>AllowOverride none<\/em>\uff0c.htaccess\u6587\u4ef6\u5c06\u5bf9\u6574\u4e2a\u5b50\u76ee\u5f55\u6811\u4e0d\u53ef\u7528\u3002<\/p>\n<p><strong>4.3 ? ?RewriteRule\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u5b9a\u4e49URL\u91cd\u5199\u89c4\u5219<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteRule?<em>Pattern Substitution<\/em>?[flags]<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u5b9a\u4e49\u4e86\u5355\u4e2aURL\u91cd\u5199\u64cd\u4f5c\u3002\u5b83\u53ef\u80fd\u5728\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\u51fa\u73b0\u591a\u6b21\uff0c\u6bcf\u4e2a\u5b9e\u4f8b\u5b9a\u4e49\u4e00\u4e2a\u91cd\u5199URL\u7684\u89c4\u5219\u3002RewriteRule\u6307\u4ee4\u5305\u542bURL\u5339\u914d\u6a21\u5f0f\u3001\u66ff\u6362\u5b57\u7b26\u4e32\u4ee5\u53ca\u53ef\u9009\u7684\u6807\u5fd7\u8bbe\u7f6e\u3002<br \/>\n<strong><em>Pattern<\/em><\/strong>\uff08\u6a21\u5f0f\uff09\u662f\u4e00\u4e2a\u7528\u6765\u5339\u914d\u5f53\u524dURL\u7684Perl\u517c\u5bb9\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u5f53\u524d\u7684URL\u53ef\u4ee5\u662f\u539f\u6765\u8bf7\u6c42\u7684URL\u6216\u8005\u5df2\u7ecf\u7531\u4f18\u5148\u7ea7\u9ad8\u7684\u89c4\u5219\u66ff\u6539\u8fc7\u7684URL\u3002\u7f51\u5740\u4ece\u4e0d\u5305\u542b\u534f\u8bae\u6216\u8005\u4e3b\u673a\u540d\uff0c\u4ece\u7b2c\u4e00\u4e2a\u659c\u6760\u5b57\u7b26\u5f00\u59cb\uff08\u53ea\u5bf9httpd.conf\u6587\u4ef6\u9002\u7528\uff09\u3002\u800c\u4e14\u5f53\u524d\u7f51\u5740\u8fd8\u56e0\u4e0d\u540c\u7684\u5e94\u7528\u914d\u7f6e\u7ea7\u522b\u800c\u5f02\u3002\u5bf9\u4e8e\u76ee\u5f55\u7ea7\u914d\u7f6e\uff08.htaccess\u6587\u4ef6\uff09\uff0c\u7ed3\u5c3e\u7684\u659c\u7ebf\u548c\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\u540d\uff0c\u4f1a\u5728\u5339\u914d\u65f6\u88ab\u4eceURL\u4e2d\u5ffd\u7565\u6389\u3002\u5728\u521b\u5efa\u6b63\u5219\u8868\u8fbe\u5f0f\u65f6\uff0c\u8bf7\u9605\u8bfb\u8fd9\u4e2a\u6587\u6863\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u90e8\u5206\u6765\u5f97\u5230\u66f4\u591a\u7684\u4fe1\u606f\u3002<br \/>\n&#8220;!&#8221;\u5b57\u7b26\u6253\u5934\u7684\u6a21\u5f0f\u5c06\u5426\u5b9a\u6574\u4e2a\u8868\u8fbe\u5f0f\u3002\u5426\u5b9a\u6a21\u5f0f\u4e0d\u80fd\u4ea7\u751f\u5b50\u5339\u914d\uff0c\u6240\u4ee5\u4f60\u4e0d\u80fd\u4f7f\u7528$N\u7684\u66ff\u4ee3\u5f15\u7528\u3002<br \/>\n<strong><em>Substitution<\/em><\/strong>(\u66ff\u6362)\u5b57\u7b26\u4e32\u6307\u5b9a\u4e86\u6a21\u5f0f\u662f\u5339\u914d\u65f6\u751f\u6210URL\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\u3002\u9664\u4e86\u7eaf\u6587\u672c\uff0c\u5b83\u53ef\u4ee5\u5305\u62ec\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26\u3002<br \/>\n? \u5bf9Rewrite\u6a21\u5f0f\u7684\u56de\u6eaf\u5f15\u7528?<strong>$N<\/strong><br \/>\n? \u5bf9Rewrite\u6a21\u5f0f\u7684\u56de\u6eaf\u5f15\u7528?<strong>%N<\/strong><br \/>\n? \u670d\u52a1\u5668\u53d8\u91cf?<strong>%{VARNAME}<\/strong><br \/>\n? \u6761\u4ef6\u683c\u5f0f\u6a21\u5f0f?<strong>?Ntrue_string:false_string?<\/strong><br \/>\n? \u5206\u7ec4\u62ec\u53f7\u201c<strong>(<\/strong>\u201d\u548c\u201c<strong>)<\/strong>\u201d<br \/>\n\u66ff\u6362\u5b57\u7b26\u4e32\u5c06\u6240\u6709\u7684\u5b57\u7b26\u89c6\u4e3a\u5b57\u9762\u503c\uff0c\u9664\u4e86$&#8217;\u3001&#8217;\\&#8217;\u3001'(&#8216;\u3001&#8217;)&#8217;\uff0c&#8217;?&#8217;\uff0c&#8217;:&#8217;\u548c&#8217;\\&#8217;\u3002\u4e3a\u4e86\u5b57\u9762\u5316\u5730\u8bfb\u51fa\u7279\u6b8a\u5b57\u7b26\uff0c\u5b83\u5b9a\u4e49\u4e86\u7528&#8221;<strong>\\<\/strong>&#8220;\u5f15\u5bfc\u7684\u8f6c\u4e49\u5b57\u7b26\u3002\u4e0b\u9762\u7684\u7279\u6b8a\u5b57\u7b26\u662f\u5141\u8bb8\u7684\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td>$&amp;<\/td>\n<td>\u8f93\u51fa\u5339\u914d\u7684\u6574\u4e2a\u8868\u8fbe\u5f0f\u3002<\/td>\n<\/tr>\n<tr>\n<td>$`<\/td>\n<td>\u8f93\u51fa\u4e0a\u4e00\u4e2a\u7684\u5339\u914d\u7ed3\u675f\u5230\u5f53\u524d\u5339\u914d\u7684\u5f00\u59cb\u4e4b\u95f4\u7684\u6587\u672c(\u5982\u679c\u4e4b\u524d\u6ca1\u6709\u627e\u5230\u5339\u914d\u4e32\uff0c\u5219\u8f93\u51fa\u4ece\u5f00\u5934\u5230\u5f53\u524d\u5339\u914d\u7684\u5f00\u59cb\u4e4b\u95f4\u7684\u6587\u672c)\u3002<\/td>\n<\/tr>\n<tr>\n<td>$&#8217;<\/td>\n<td>\u8f93\u51fa\u5f53\u524d\u5339\u914d\u4e4b\u540e\u8ddf\u7740\u7684\u6240\u6709\u6587\u5b57\u3002<\/td>\n<\/tr>\n<tr>\n<td>$$<\/td>\n<td>\u8f93\u51fa\u5b57\u9762\u503c$<\/td>\n<\/tr>\n<tr>\n<td>\\a<\/td>\n<td>\u4fe1\u53f7\u94c3\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\f<\/td>\n<td>\u8868\u5355\u53cd\u9988\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\n<\/td>\n<td>\u65b0\u884c\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\r<\/td>\n<td>\u56de\u8f66\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\t<\/td>\n<td>\u5236\u8868\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\v<\/td>\n<td>\u5782\u76f4\u5236\u8868\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\x<\/td>\n<td>\u5341\u516d\u8fdb\u5236\u5b57\u7b26\uff0c\u6bd4\u5982\u8bf4\\x0D.<\/td>\n<\/tr>\n<tr>\n<td>\\x{}<\/td>\n<td>\u4e00\u4e2a\u53ef\u80fd\u7684Unicode\u5341\u516d\u8fdb\u5236\u5b57\u7b26-\u4f8b\u5982\\x{1A0}<\/td>\n<\/tr>\n<tr>\n<td>\\cx<\/td>\n<td>ASCII\u7684\u8f6c\u4e49\u5b57\u7b26x\uff0c\u4f8b\u5982\\c @\u7b49\u4ef7\u4e8eescape-@\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\e<\/td>\n<td>The ASCII \u8f6c\u4e49\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\dd<\/td>\n<td>\u516b\u8fdb\u5236\u5b57\u7b26\u5e38\u91cf\uff0c\u4f8b\u5982\\10\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\l<\/td>\n<td>\u5bfc\u81f4\u4e0b\u4e00\u4e2a\u5b57\u7b26\u88ab\u5c0f\u5199\u8f93\u51fa\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\u<\/td>\n<td>\u5bfc\u81f4\u4e0b\u4e00\u4e2a\u5b57\u7b26\u88ab\u5927\u5199\u8f93\u51fa\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\L<\/td>\n<td>\u5bfc\u81f4\u6574\u4e2a\u540e\u7ee7\u5b57\u7b26\u4e32\u88ab\u5c0f\u5199\u8f93\u51fa\uff0c\u76f4\u5230\u9047\u5230\\E\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\U<\/td>\n<td>\u5bfc\u81f4\u6574\u4e2a\u540e\u7ee7\u5b57\u7b26\u4e32\u88ab\u5927\u5199\u8f93\u51fa\uff0c\u76f4\u5230\u9047\u5230\\E\u3002<\/td>\n<\/tr>\n<tr>\n<td>\\E<\/td>\n<td>\u7ed3\u675f\\L\u6216\u8005\\U\u7684\u540e\u7eed\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>\\\\<\/td>\n<td>\u5355\u4e2a\u53cd\u659c\u6760\u5b57\u7b26&#8217;\\&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>RewriteRule<\/strong>\u4ece\u7236\u914d\u7f6e\u6587\u4ef6\u5f00\u59cb\u6309\u7167\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u51fa\u73b0\u7684\u6b21\u5e8f\u5e94\u7528\u3002\u6bcf\u4e2a\u89c4\u5219\u53ea\u6709\u5728\u5b83\u7684<em>Pattern<\/em>\u5339\u914d\u4e86\u4e00\u4e2aURL\u800c\u4e14\u6240\u6709\u8fde\u63a5\u6761\u4ef6\uff08RewriteCond\uff09\u90fd\u5339\u914d\u65f6\u624d\u4f1a\u88ab\u5e94\u7528\u3002\u5728\u8be5URL\u7528Substitution\u5b8c\u6210\u66ff\u6362\u4e4b\u540e\uff0c\u91cd\u5199\u8fc7\u7a0b\u8fd8\u5728\u7ee7\u7eed\uff0c\u4e00\u76f4\u5230\u914d\u7f6e\u6587\u4ef6\u7ed3\u675f\u6216\u8005\u9047\u5230\u4e00\u4e2a\u7528\u4e86\u4efb\u4f55\u505c\u6b62\u6807\u5fd7\u7684\u89c4\u5219\u3002\u5728<em>Substitution<\/em>\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u4e32&#8221;-&#8220;(\u77ed\u6a2a)\u610f\u5473\u7740\u6ca1\u6709\u66ff\u6362\uff0c\u800c\u4e14\u5f53\u4f60\u9700\u8981\u5e94\u7528\u8be5\u89c4\u5219\u5e76\u7559\u4e0b\u7684\u539f\u59cb\u7684\u672a\u88ab\u67d3\u6307\u8fc7\u7684URL\u65f6\u5b83\u662f\u5f88\u6709\u7528\u7684\u3002<br \/>\n\u6b64\u5916\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u652f\u6301\u7684<strong>flag<\/strong>(\u6807\u5fd7)\u5217\u8868\u3002\u8fd9\u4e9b\u6807\u8bc6\u53ef\u4ee5\u6539\u53d8\u89c4\u5219\u7684\u8868\u73b0\u3002<br \/>\n\u4e0eApache\u5b8c\u5168\u517c\u5bb9\u7684\u6807\u5fd7\u88ab\u6807\u8bb0\u4e3a\u7eff\u8272\uff0c\u90e8\u5206\u517c\u5bb9\u6216\u4e0b\u4e00\u7248\u8ba1\u5212\u517c\u5bb9\u7684\u9ec4\u8272\uff0c\u4e0d\u517c\u5bb9\u7684\u6807\u8bb0\u4e3a\u7ea2\u8272\u3002<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>RewriteRule\n<ul>\n<li>$N rule backreferences<\/li>\n<li>%N RewriteCond backreferences<\/li>\n<li>${mapname:key|default}<\/li>\n<li>%{VARNAME} server variables<\/li>\n<li>&#8216;!&#8217; negation<\/li>\n<li>[C] chain with next rule<\/li>\n<li>[CO=name:val:domain:lifetime:path] set cookie<\/li>\n<li>[E=var:val] set environment variable<\/li>\n<li>[F] force forbidden response<\/li>\n<li>[G] force gone response<\/li>\n<li>[H=content-handler] explicit content handler (unapplicable)<\/li>\n<li>[L] last rule flag<\/li>\n<li>[N] apply rules again<\/li>\n<li>[NC] ignore case<\/li>\n<li>[NE] don&#8217;t escape output<\/li>\n<li>[NS] no internal subrequest<\/li>\n<li>[P] proxy pass<\/li>\n<li>[PT] pass through the next handler (always on)<\/li>\n<li>[QSA] append query string<\/li>\n<li>[R =code] redirect<\/li>\n<li>[S=num] skip next?<em>n<\/em>?rules<\/li>\n<li>[T=MIME-type] force explicit response MIME type<\/li>\n<\/ul>\n<\/li>\n<li>RewriteCond\n<ul>\n<li>[NC] ignore case<\/li>\n<li>[OR] logical or combining<\/li>\n<li>%{HTTP:header}<\/li>\n<li>&#8216;!&#8217; negation<\/li>\n<li>&#8216;&lt;CondPattern&#8217; more than comparison<\/li>\n<li>&#8216;&gt;CondPattern&#8217; less then comparison<\/li>\n<li>&#8216;=CondPattern&#8217; equal to comparison<\/li>\n<li>&#8216;-d&#8217; directory exist<\/li>\n<li>&#8216;-f&#8217; file exist<\/li>\n<li>&#8216;-s&#8217; non zero file<\/li>\n<li>&#8216;-l&#8217; symbolic link<\/li>\n<li>&#8216;-x&#8217; file with executable permissions<\/li>\n<li>&#8216;-F&#8217; file exist via subrequest<\/li>\n<li>\n<div align=\"left\">&#8216;-U&#8217; URL exist via subrequest<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>4.4RewriteCond\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u4e3a\u4ee5\u4e0b\u7684RewriteRule\u5b9a\u4e49\u4e00\u4e2a\u6761\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteCond<em>?TestString CondPattern<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8be5\u6307\u4ee4\u4e3a\u540e\u9762\u7684RewriteRule\uff0cRewriteHeader\u6216RewriteProxy\u6307\u4ee4\u89c4\u5b9a\u4e86\u4e00\u4e2a\u6761\u4ef6\u3002\u4e00\u4e2a\u89c4\u5219\u6307\u4ee4\u524d\u53ef\u4ee5\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u6761\u4ef6\uff0c\u89c4\u5219\u53ea\u6709\u5728\u6240\u6709\u6761\u4ef6\u5f97\u5230\u6ee1\u8db3\u7684\u60c5\u51b5\u4e0b\u624d\u88ab\u5e94\u7528\u3002<br \/>\n<strong><em>TestString<\/em><\/strong>\u9644\u52a0\u5230\u7eaf\u6587\u672c\u53ef\u4ee5\u5305\u542b\u4e0b\u5217\u7ed3\u6784\u3002<br \/>\n? \u7528\u8bed\u6cd5<strong>$N<\/strong>\u56de\u6eaf\u5f15\u7528RewriteRule\u6a21\u5f0f<br \/>\n? \u7528\u8bed\u6cd5<strong>%N<\/strong>\u56de\u6eaf\u5f15\u7528\u524d\u9762\u7684RewriteCond\u6a21\u5f0f<br \/>\n? \u7528\u8bed\u6cd5<strong>${mapname:key|default}<\/strong>\u6269\u5c55RewriteMap<br \/>\n? \u7528\u8bed\u6cd5<strong>%{HTTP:header}<\/strong>\u6307\u4ee3HTTP\u5934\u503c<br \/>\n? \u7528\u8bed\u6cd5<strong>%{NAME_OF_VARIABLE}<\/strong>\u6307\u4ee3\u670d\u52a1\u5668\u53d8\u91cf<\/p>\n<p>\u4ee5\u4e0b\u662f\u53ef\u7528\u7684\u670d\u52a1\u5668\u53d8\u91cf\u5217\u8868\uff1a<\/p>\n<table>\n<tbody>\n<tr>\n<td>HTTP_USER_AGENT<br \/>\nHTTP_REFERER<br \/>\nHTTP_COOKIE<br \/>\nHTTP_FORWARDED<br \/>\nHTTP_HOST<br \/>\nHTTP_PROXY_CONNECTION<br \/>\nHTTP_ACCEPT<br \/>\nREMOTE_ADDR<br \/>\nREMOTE_HOST<br \/>\nREMOTE_PORT<br \/>\nREMOTE_USER<br \/>\nREMOTE_IDENT<br \/>\nREQUEST_METHOD<br \/>\nSCRIPT_FILENAME<br \/>\nPATH_INFO<br \/>\nQUERY_STRING<br \/>\nAUTH_TYPE<\/td>\n<td>DOCUMENT_ROOT<br \/>\nSERVER_NAME<br \/>\nSERVER_ADDR<br \/>\nSERVER_PORT<br \/>\nSERVER_PROTOCOL<br \/>\nSERVER_SOFTWARE<br \/>\nAPI_VERSION<br \/>\nTHE_REQUEST<br \/>\nREQUEST_URI<br \/>\nREQUEST_FILENAME<br \/>\nHTTPS<\/td>\n<td>TIME_YEAR<br \/>\nTIME_MON<br \/>\nTIME_DAY<br \/>\nTIME_HOUR<br \/>\nTIME_MIN<br \/>\nTIME_SEC<br \/>\nTIME_WDAY<br \/>\nTIME<br \/>\n\u53e6\u5916\uff0c\u6240\u6709\u7684IIS\u7279\u6709\u7684\u53d8\u91cf\u90fd\u662f\u652f\u6301\u7684\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>CondPattern\u6307\u5b9a\u4e00\u4e2a\u5e94\u7528\u4e8eTestString\u5b9e\u4f8b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u4ee5\u4e0b\u7279\u6b8a\u503c\u4e5f\u652f\u6301\uff1a<br \/>\n1.\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u524d\u5934\u52a0\u201c!\u201d\u7b26\u53f7\u6307\u660e\u5426\u5b9a\u6a21\u5f0f\u3002<br \/>\n2.<strong>&#8216;&lt;CondPattern&#8217;<\/strong>\u5c06CondPattern\u4f5c\u4e3a\u4e00\u4e2a\u7eaf\u5b57\u7b26\u4e32\u6309\u5b57\u5178\u987a\u5e8f\u6bd4\u8f83\uff0c\u7ed3\u679c\u6bd4\u8f83\u5927<br \/>\n3.<strong>&#8216;&gt;CondPattern&#8217;<\/strong>\u6309\u5b57\u5178\u987a\u5e8f\u6bd4\u8f83\uff0c\u7ed3\u679c\u6bd4\u8f83\u5c0f<br \/>\n4.<strong>&#8216;=CondPattern&#8217;<\/strong>\u6309\u5b57\u5178\u987a\u5e8f\u6bd4\u8f83\uff0c\u7ed3\u679c\u76f8\u7b49<br \/>\n5.<strong>&#8216;-d&#8217;<\/strong>?\u68c0\u6d4b\u5b57\u7b26\u4e32\u662f\u5426\u5b58\u5728\u76ee\u5f55\u3002<br \/>\n6.<strong>&#8216;-f&#8217;<\/strong>?\u68c0\u6d4b\u5b57\u7b26\u4e32\u662f\u5426\u5b58\u5728\u6587\u4ef6\u3002<br \/>\n7.<strong>&#8216;-s&#8217;<\/strong>?\u68c0\u6d4b\u5b57\u7b26\u4e32\u662f\u4e0d\u662f\u4e00\u4e2a\u975e\u96f6\u5927\u5c0f\u7684\u6587\u4ef6\u3002<br \/>\n8.<strong>&#8216;-l&#8217;<\/strong>?(\u94fe\u63a5) \u4e0d\u652f\u6301\u7684\uff0c\u59cb\u7ec8\u4e3afalse\u3002<br \/>\n9.<strong>&#8216;-x&#8217;<\/strong>?(\u62e5\u6709\u53ef\u6267\u884c\u6743\u9650) \u4e0d\u652f\u6301\u7684\uff0c\u59cb\u7ec8\u4e3atrue\u3002<br \/>\n10.<strong>&#8216;-F&#8217;<\/strong>?(\u5b58\u5728\u7684\u6587\u4ef6\uff0c\u901a\u8fc7\u5b50\u8bf7\u6c42) \u4e0d\u652f\u6301\uff0c\u548c&#8217;?Cf&#8217;\u4e00\u6837\u3002<br \/>\n11.&#8217;-U&#8217; (\u5b58\u5728\u7684URL\uff0c\u901a\u8fc7\u5b50\u8bf7\u6c42) \u4e0d\u652f\u6301\u7684\uff0c\u59cb\u7ec8\u4e3afalse\u3002<\/p>\n<p>\u4e0b\u9762\u7684\u6807\u8bb0\u4e5f\u662f\u652f\u6301\u7684\uff1a<br \/>\n<strong>&#8216;nocase|NC&#8217;<\/strong><br \/>\n\u8fd9\u4e2a\u6807\u8bb0\u4f7f\u6a21\u5f0f\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002<br \/>\n<strong>&#8216;ornext|OR&#8217;?<\/strong><br \/>\n\u8fd9\u4e2a\u6807\u8bb0\u7528\u903b\u8f91\u6216\u800c\u4e0d\u662f\u9690\u542b\u7684\u903b\u8f91\u4e0e\u7ed3\u5408\u5b50\u8bf7\u6c42RewriteCond\u6307\u4ee4\u3002<br \/>\n<strong>O<\/strong><br \/>\n\u7559\u7528\u4e8eISAPI_Rewrite 2.x\u7684\u517c\u5bb9\u6027\u3002\u5728\u5904\u7406\u524d\u89c4\u8303\u5316\u5b57\u7b26\u4e32\u3002\u89c4\u8303\u5316\u5305\u62ec\u79fb\u9664\u4e00\u4e2aURL\u7f16\u7801\u3001\u9519\u8bef\u5b57\u7b26\uff0c\u7b49\u7b49\u3002\u540c\u65f6URL\u7684\u89c4\u8303\u5316\u5c06\u5b8c\u5168\u79fb\u9664\u5b83\u7684\u67e5\u8be2\u5b57\u7b26\u4e32\u3002<\/p>\n<p><strong>4.5RewriteBase\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u4e3a\u6bcf\u4e2a\u76ee\u5f55\u7684\u91cd\u5199\u8bbe\u7f6e\u4e00\u4e2a\u57fa\u51c6\u7684URL<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteBase?<em>URL-path<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td>RewriteBase?<em>requested-directory-path<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5f53RewriteRule\u6307\u4ee4\u7528\u4e8e\u6bcf\u4e2a\u76ee\u5f55\u7684\u914d\u7f6e\u6587\u4ef6(.htaccess)\u65f6\uff0c\u5b83\u5c06\u81ea\u52a8\u4ece\u8def\u5f84\u4e2d\u5265\u53bb\u672c\u5730\u76ee\u5f55\u524d\u7f00\uff0c\u53ea\u5bf9\u5269\u4e0b\u7684\u90e8\u5206\u5e94\u7528\u89c4\u5219\u3002<strong>RewriteBase<\/strong>\u6307\u4ee4\u5141\u8bb8\u4f60\u4e3a\u8fd9\u4e9b\u89c4\u5219\u7cbe\u786e\u6307\u5b9a\u4e00\u4e2a\u57fa\u51c6\u3002\u6bd4\u5982\uff0c\u54ea\u90e8\u5206\u8981\u88ab\u5265\u79bb\u3002<br \/>\n\u548cApache\u7684mod_rewrite\u4e0d\u540c\uff0cISAPI_Rewrite\u7684\u8bbf\u95ee\u4e0d\u4ec5\u4ec5\u9488\u5bf9\u4e8e\u7269\u7406\u8def\u5f84\uff0c\u540c\u65f6\u8fd8\u9488\u5bf9\u4e8e\u865a\u62df\u8def\u5f84\uff0c\u800c\u4e14\u53ef\u4ee5\u81ea\u52a8\u5730\u9009\u62e9\u6b63\u786e\u7684\u57fa\u51c6\u3002\u6240\u4ee5\u8fd9\u4e2a\u6307\u4ee4\u53ea\u662f\u4e3a\u4e86\u517c\u5bb9\u6027\u539f\u56e0\u800c\u88ab\u4fdd\u7559\u7684\u3002<br \/>\n<strong><em>URL-path<\/em><\/strong>\u53ef\u4ee5\u662f\u76f8\u5bf9\u4e8e\u6839\u7684\u8def\u5f84\u4e5f\u53ef\u4ee5\u662f\u7a7a\uff0c\u7a7a\u7684<em>URL-path<\/em>\u610f\u5473\u7740\u89c4\u5219\u7684\u57fa\u51c6\u7b49\u540c\u4e8e\u7f51\u7ad9\u7684\u6839\u76ee\u5f55\u3002<\/p>\n<p><strong>4.6?? RewriteProxy\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u4ee3\u7406\u8bf7\u6c42\u5230\u4e00\u4e2a\u8fdc\u7a0b\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteProxy?<em>Pattern Substitution [flags]<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f7f\u7ed3\u679cURL\u88ab\u5185\u90e8\u5904\u7406\u4e3a\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u7684\u76ee\u6807\uff0c\u5e76\u5373\u65f6\u4f20\u9012\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u4ece\u6b64\u4e2d\u65ad\u4e86\u89c4\u5219\u5904\u7406\u3002\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u54cd\u5e94\u5c06\u88ab\u4f20\u9012\u56de\u5ba2\u6237\u7aef\u3002\u4ee3\u7406\u8981\u6c42\u60a8\u6307\u5b9a\u5b8c\u6574\u7684URL\uff0c\u7531\u534f\u8bae\uff0c\u4e3b\u673a\u540d\u79f0\u7b49\u5f00\u5934\u3002ISAPI_Rewrite\u4f7f\u7528ISAPI\u6269\u5c55\u6765\u5904\u7406\u4ee3\u7406\u8bf7\u6c42\u3002\u4f60\u53ef\u4ee5\u5728\u914d\u7f6e\u4ee3\u7406\u7684\u7ae0\u8282\u91cc\u9605\u8bfb\u5230\u66f4\u591a\u3002<br \/>\n\u8bed\u6cd5\u548c\u64cd\u4f5c\u7b26\u4e0eRewriteRule\u6307\u4ee4\u662f\u76f8\u540c\u7684\u3002\u4f46\u662fRewroteProxy\u6307\u4ee4\u652f\u6301\u4e00\u4e9b\u989d\u5916\u7684\u6807\u8bb0\u3002<br \/>\n<strong>H?<\/strong>(preserve Host)<br \/>\n\u4ee3\u7406\u6a21\u5757\u5728\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\u65f6\u5c06\u4f7f\u7528\u968f\u7740\u6e90\u8bf7\u6c42\u4e00\u8d77\u53d1\u9001\u8fc7\u6765\u7684\u4e3b\u673a\u5934\uff0c\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\u6807\u5fd7\u4ee3\u7406\u670d\u52a1\u5668\u5219\u5c06\u7528\u4e3b\u673a\u540d\u548c\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u7aef\u53e3\u53f7\u7ec4\u6210\u4e3b\u673a\u5934\u3002<br \/>\n<strong>A?<\/strong>(<strong>A<\/strong>dd authentication headers)<br \/>\n\u5141\u8bb8\u4ece\u4ee3\u7406\u670d\u52a1\u5668\u5c06\u4e00\u4e2a\u8ba4\u8bc1\u4fe1\u606f\u4f20\u9012\u5230\u5c40\u57df\u7f51\u670d\u52a1\u5668\u4e0a\uff0c\u5f53\u5ba2\u6237\u7aef\u8ba4\u8bc1\u548c\u4ee3\u7406\u670d\u52a1\u5668\u51b2\u7a81\u65f6\u5b83\u5f88\u6709\u7528\u3002\u670d\u52a1\u6a21\u5757\u5c06\u5bf9\u4e00\u4e2a\u8bf7\u6c42\u7684\u670d\u52a1\u5668\u53d8\u91cf<\/p>\n<pre>AUTH_TYPE,AUTH_USER,LOGON_USER,REMOTE_USER<\/pre>\n<p>\u8ffd\u52a0\u76f8\u5e94\u7684\u5934<\/p>\n<pre>X-ISRW-Proxy-AUTH-TYPE,X-ISRW-Proxy-AUTH-USER,X-ISRW-Proxy-LOGON-USER,X-ISRW-Proxy-REMOTE-USER<\/pre>\n<p>\u5230\u88ab\u4ee3\u7406\u7684\u670d\u52a1\u5668\u3002<br \/>\n<strong>CR?<\/strong>(use Credentials)<br \/>\n\u4ee3\u7406\u6a21\u5757\u5c06\u5c1d\u8bd5\u7528\u5728URL\u4e2d\u6307\u5b9a\u7684\u8bc1\u4e66\u8eab\u4efd\u9a8c\u8bc1\u767b\u5f55\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u6216\u8005\u7528\u57fa\u672c\u8eab\u4efd\u9a8c\u8bc1\u5934\u767b\u5f55\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u7528\u4e86\u8fd9\u4e2a\u6807\u5fd7\uff0c\u4f60\u53ef\u4ee5\u5728\u4e00\u4e2a\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528http:\/\/user:password@host.com\/page\u8bed\u6cd5\u4f5c\u4e3a\u4e00\u4e2aURL\u3002<\/p>\n<p><strong>4.7?? RewriteHeader\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u91cd\u5199\u4efb\u4f55\u8bf7\u6c42\u7684HTTP\u5934<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteHeader?<em>HeaderName: Pattern Substitution [flags]<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2aRewriteHeader\u6307\u4ee4\u662f<em>RewriteRule<\/em>\u6307\u4ee4\u4e2d\u7684\u4e00\u4e2a\u5f88\u5e38\u7528\u7684\u53d8\u91cf\u3002\u800c\u4e14\u5b83\u88ab\u8bbe\u8ba1\u7528\u6765\u91cd\u5199\u5ba2\u6237\u7aef\u7684URL\u90e8\u5206\u4ee5\u53caHTTP\u5934\u7684\u90e8\u5206\u3002\u6280\u672f\u4e0a\u7684<em>RewriteRule<\/em>\u6307\u4ee4\uff0c\u76f8\u5f53\u4e8e<em>RewriteHeader<\/em>\u7684<em>URL Pattern Substitution [flag]<\/em>\u3002\u8fd9\u4e2a\u6307\u4ee4\u53ef\u7528\u4e8e\u5728IIS\u91cc\u66f4\u591a\u5e94\u7528\u7a0b\u5e8f\u7684\u5904\u7406\u4e4b\u524d\u91cd\u5199\u3001\u521b\u5efa\u6216\u8005\u5220\u9664\u4efb\u4f55\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684HTTP\u5934\u3002<br \/>\n<strong><em>HeaderName<\/em><\/strong>\uff1a\u6307\u5b9a\u5c06\u88ab\u91cd\u5199\u7684HTTP\u5934\u7684\u540d\u5b57\u3002<br \/>\n<em>pattern<\/em>\u3001<em>Substitution<\/em>\u548c<em>flag<\/em>\u4e0eRewriteRule\u6307\u4ee4\u4e2d\u90fd\u662f\u76f8\u540c\u7684\u3002<\/p>\n<p><strong>4.8? RewriteMap\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u4e3a\u4e00\u4e2a\u6620\u5c04\u51fd\u6570\u503c\u5b9a\u4e49\u4e00\u4e2a\u952e<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteMap<em>?MapName MapType:MapSource<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>RewriteMap<\/em>\u6307\u4ee4\u88ab\u7528\u6765\u5b9a\u4e49\u4e00\u4e2a\u952e\u5230\u503c\u7684\u67e5\u627e\u529f\u80fd\u3002\u5f53\u4f60\u9700\u8981\u6620\u5c04\u5927\u91cf\u7684\u503c\u65f6\uff0c\u5b83\u4f1a\u5f88\u6709\u7528\u7684\uff0c\u800c\u4e14\u5b83\u7684\u901f\u5ea6\u8fdc\u8fdc\u5feb\u8fc7\u7528\u89c4\u5219\u5339\u914d\u6765\u505a\u5230\u5b83\u3002\u6620\u5c04\u529f\u80fd\u7684\u6027\u80fd\u53d7\u6620\u5c04\u6587\u4ef6\u7684\u5927\u5c0f\u5f71\u54cd\u5fae\u4e4e\u5176\u5fae\u3002\u6709\u4e09\u79cd\u7c7b\u578b\u7684\u6620\u5c04\uff1a<br \/>\n??<strong>txt<\/strong>\uff1a\u7528\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u6620\u5c04<br \/>\n??<strong>rnd<\/strong>\uff1a\u4ece\u591a\u4e2a\u53ef\u9009\u9879\u4e2d\u4ea7\u751f\u968f\u673a\u503c<br \/>\n??<strong>int<\/strong>\uff1a\u5185\u90e8\u51fd\u6570<br \/>\n<strong><em>MapName<\/em><\/strong>\u662f\u8fd9\u4e2a\u6620\u5c04\u529f\u80fd\u7684\u540d\u5b57\uff0c\u5728RewriteRule\u547d\u4ee4\u4e2d\u88ab\u7528\u6765\u6307\u5b9a\u8fd9\u4e2a\u6620\u5c04\u3002\u8bf7\u786e\u4fdd\u6bcf\u4e2a\u6620\u5c04\u7528\u552f\u4e00\u7684\u540d\u79f0\u5b9a\u4e49\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u5728RewriteRule\u6307\u4ee4\u7684<em>Substitution<\/em>\u53c2\u6570\u4e2d\u8c03\u7528\u6620\u5c04\u529f\u80fd<\/p>\n<pre>${ MapName : LookupKey | DefaultValue }<\/pre>\n<p>\u5982\u679c\u8fd9\u4e2a\u7ed3\u6784\u662f\u5728<em>Substitution<\/em>\u4e2d\u51fa\u73b0\uff0cISAPI_Rewrite\u5c06\u5728\u6620\u5c04\u4e2d\u67e5\u627e\u8fd9\u4e2a\u952e\uff0c\u4e07\u4e00\u627e\u5230\u4e86\u4e00\u4e2a\uff0c\u5c31\u7528\u5b83\u7684\u503c\u66ff\u6362\u8fd9\u4e2a\u7ed3\u6784\u3002\u5982\u679c\u4ec0\u4e48\u503c\u4e5f\u6ca1\u6709\u88ab\u627e\u5230\uff0c\u5c06\u7528\u53ef\u9009\u7684DefaultValue\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9aDefaultValue\uff0c\u5b83\u5c06\u7528\u4e00\u4e2a\u7a7a\u4e32\u66ff\u6362\u3002<br \/>\n\u4e0b\u9762\u7684\u6807\u5fd7\u4e5f\u662f\u652f\u6301\u7684\uff1a<br \/>\n<strong>\u2018nocase|NC\u2019<\/strong><br \/>\n\u8fd9\u4e2a\u6807\u5fd7\u4f7f\u8be5\u67e5\u627e\u952e\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002<br \/>\n<strong>\u4e0b\u9762\u662f\u4e00\u4e2a\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u6620\u5c04\u6587\u4ef6\u6307\u4ee4\u7684\u793a\u4f8b<\/strong><\/p>\n<pre>RewriteMap examplemap txt:C:\/path\/to\/file\/map.txt [NC]<\/pre>\n<p>\u5230<em>MapSource<\/em>\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u65e2\u53ef\u4ee5\u662f\u7edd\u5bf9\u5730\u5740\u4e5f\u53ef\u4ee5\u662f\u76f8\u5bf9\u5730\u5740\u3002\u76f8\u5bf9\u5730\u5740\u5c06\u88ab\u4ece\u5f53\u524d\u914d\u7f6e\u7684\u6587\u4ef6\u5939\u5f00\u59cb\u63a8\u7b97\uff0c\u6362\u8a00\u4e4b\uff0c\u5c31\u662f\u4ece\u8fd9\u4e2a\u5b9a\u4e49\u6620\u5c04\u7684\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\u5f00\u59cb\u63a8\u7b97\u3002<br \/>\n\u7136\u540e\u4f60\u53ef\u4ee5\u5728RewriteRule\u4e2d\u5982\u4e0b\u4f7f\u7528\u8fd9\u4e2a\u6620\u5c04\uff1a<\/p>\n<pre>RewriteRule ^\/ex\/(.*) ${examplemap:$1}<\/pre>\n<p>\u4e0b\u5217<em>MapType<\/em>\u548c<em>MapSource<\/em>\u7684\u7ec4\u5408\u662f\u53ef\u7528\u7684\uff1a<br \/>\n<strong>txt<\/strong>\uff1a\u7eaf\u6587\u672c\u6620\u5c04\uff0c\u5b83\u7684source\u662f\u5230\u4e00\u4e2a\u53ef\u7528\u7684\u6587\u672c\u6587\u6863\u7684windows\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\u3002\u6587\u672c\u6587\u6863\u5fc5\u987b\u662f\u5982\u4e0b\u683c\u5f0f\u7684\uff1a<\/p>\n<pre>#This is a commentkey1 value1 #Another commentkey2 value2keyN valueN<\/pre>\n<p><strong>rnd<\/strong>\uff1a\u968f\u673a\u67e5\u627e\u591a\u4e2a\u503c\u3002Source\u662f\u4e00\u4e2a\u6587\u672c\u6587\u6863\u7684\u8def\u5f84\uff0c\u6587\u672c\u6587\u6863\u5fc5\u987b\u662f\u4ee5\u4e0b\u683c\u5f0f\uff1a<\/p>\n<pre>#This is a commentkey1 value1|value2|value3key2 value4|value5|value6|valueN<\/pre>\n<p><strong>int:<\/strong>?\u8c03\u7528\u5185\u90e8\u51fd\u6570\u3002 Source\u5fc5\u987b\u662f\u4e0b\u5217\u9884\u5b9a\u4e49\u7684\u5185\u90e8\u51fd\u6570\u4e4b\u4e00\uff1a<br \/>\n??<strong>toupper:<\/strong>?\u8f6c\u6362\u5173\u952e\u8bcd\u4e3a\u5927\u5199\u5f62\u5f0f\u3002<br \/>\n??<strong>tolower:<\/strong>\u8f6c\u6362\u5173\u952e\u8bcd\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002<br \/>\n??<strong>escape:<\/strong>\u628a\u7279\u5b9a\u5b57\u7b26\u7f16\u7801\u4e3a\u5341\u516d\u8fdb\u5236\u3002<br \/>\n??<strong>unescape:<\/strong>\u628a\u5341\u516d\u8fdb\u5236\u503c\u7f16\u8bd1\u4e3a\u7279\u5b9a\u5b57\u7b26\u3002<\/p>\n<p><strong>4.9?? RewriteLog\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u8bbe\u7f6eISAPI_Rewrite\u65e5\u5fd7\u6587\u4ef6\u7684\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteLog<em>?file-path<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td>RewriteLog<em>?installdir\\rewrite.log<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u7528\u6765\u8bbe\u5b9a\u8bb0\u5f55ISAPI_Rewrite\u52a8\u4f5c\u7684\u65e5\u5fd7\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u3002\u793a\u4f8b\uff1a<\/p>\n<pre>Rewritelog \"C:\\local\\path\\rewrite.log\"<\/pre>\n<p><strong>4.10?? RewriteLogLevel\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteLogLevel?<em>Level<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td>RewriteLogLevel 0<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u8bbe\u7f6e\u65e5\u5fd7\u7684\u8f93\u51fa\u957f\u5ea6\u3002\u9ed8\u8ba4\u503c0\u8868\u793a\u4e0d\u8bb0\u65e5\u5fd7\uff0c\u800c\u6700\u5927\u7684\u7ea7\u522b9\u5219\u8868\u793a\u6240\u6709\u7684\u52a8\u4f5c\u90fd\u8981\u8bb0\u5f55\u3002<br \/>\n\u4f7f\u7528\u4f7f\u7528\u8f83\u9ad8\u7684\u7ea7\u522b\u503c\u53ef\u80fd\u4f1a\u964d\u4f4eISAPI_Rewrite\u7684\u64cd\u4f5c\u901f\u5ea6\u3002\u6211\u4eec\u5efa\u8bae\u4f60\u5f53\u4f60\u5b8c\u6210\u89c4\u5219\u8c03\u8bd5\u4e4b\u540e\uff0c\u901a\u8fc7\u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\u4e3a\u96f6\u6765\u7981\u7528\u65e5\u5fd7\u3002<\/p>\n<p><strong>4.11?? RewriteOptions\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u6307\u5b9a\u7279\u6b8a\u9009\u9879<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteOptions Options<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u53ef\u4ee5\u4e3aISAPI_Rewrite\u8bbe\u7f6e\u7279\u5b9a\u9009\u9879\u3002\u5f53\u524d\u53ea\u6709\u60df\u4e00\u4e00\u4e2a\u9009\u9879\u53ef\u7528\uff1a<strong>inherit<\/strong>\u3002<br \/>\n<strong>inherit<\/strong>\uff1a\u5f3a\u8feb\u5f53\u524d\u914d\u7f6e\u4ece\u7236\u7ea7\u7ee7\u627f\u6240\u6709\u7684\u9009\u9879\u548c\u89c4\u5219\u3002\u8fd9\u610f\u5473\u7740\u6765\u81ea\u7236\u7ea7\u914d\u7f6e\u7684\u6240\u6709\u7684\u89c4\u5219\u5c06\u88ab\u518d\u6b21\u6267\u884c\uff0c\u9664\u975e\u5f53\u524d\u73af\u5883\u53e6\u6709\u76f8\u5e94\u91cd\u5199\u89c4\u5219\u3002<\/p>\n<p><strong>4.12?? RewriteCompatibility2\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u542f\u7528\u6216\u7981\u7528ISAPI_Rewrite 2.x\u517c\u5bb9\u6a21\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>RewriteCompatibility2?<em>on<\/em>|<em>off<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td>RewriteCompatibility2 off<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e00\u6307\u4ee4\u5c06\u6fc0\u6d3b\u4e0eISAPI_Rewrite 2.x\u7248\u7684\u517c\u5bb9\u6027\uff0c\u5c06\u4e00\u4e9b2.X\u7684\u89c4\u5219\u6b63\u786e\u5730\u7ffb\u8bd1\u4e3a3.0\u7248\u672c\u7684\u8bed\u6cd5\u3002\u8fd9\u5e76\u4e0d\u610f\u5473\u7740ISAPI_Rewrite 3\u5c06\u5f00\u59cb\u61c2\u5f97\u4e0d\u7ecf\u4fee\u6539\u65e7\u7684\u8bed\u6cd5\u3002\u5982\u679c\u60a8\u6709\u9488\u5bf9ISAPI_Rewrite 2.X\u7684\u65e7\u8bbe\u8ba1\u8bf7\u4f7f\u7528ISAPI_Rewrite\u63d0\u4f9b\u7684\u7ffb\u8bd1\u5de5\u5177\u5c06\u8fd9\u4e9b\u65e7\u89c4\u5219\u8f6c\u5316\u4e3a\u65b0\u7684\u8bed\u6cd5\u89c4\u5219\u3002<br \/>\n\u73b0\u5728\u901a\u8fc7\u8bbe\u7f6e\u6307\u4ee4<em>RewriteCompatibility2<\/em>\u552f\u4e00\u6539\u53d8\u7684\u662f\uff0c\u5b83\u5c06\u5173\u95ed\u7f51\u5740\u5e38\u89c4\u524d\u7f00\u5e76\u5220\u9664\u67e5\u8be2\u5b57\u7b26\u4e32\u3002 Apache\u7684mod_rewrite\u5c06\u5220\u9664\u5339\u914d\u7684URL\u7684\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\u8fd9\u90e8\u5206\uff0c\u76f8\u8f83\u4e4b\u4e0bISAPI_Rewrite 2.X\u5c06\u5339\u914d\u6574\u4e2a\u7f51\u5740\uff08\u5305\u62ec\u67e5\u8be2\u5b57\u7b26\u4e32\u5728\u5185\uff09\uff0c\u800c\u4e14[O]\u6807\u8bb0\u7684\u610f\u601d\u5c06\u7531\u8be5\u6307\u4ee4\u5012\u7f6e\u3002<\/p>\n<p><strong>4.13ErrorLog\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u4e00\u822c\u7684\u9519\u8bef\u6587\u4ef6\u7684\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>ErrorLog<em>?file-path<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c<\/td>\n<td>ErrorLog?<em>installdir\\rewrite.log<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u8bbe\u7f6e\u5b58\u653eISAPI_Rewrite\u6574\u4f53\u9519\u8bef\u548c\u6d88\u606f\u7684\u65e5\u5fd7\u6587\u4ef6\u7684\u540d\u79f0\u3002\u4f8b\u5982httpd.conf file load, .htaccess file load,\u7b49\u7b49<br \/>\n\u4f8b\uff1aErrorLog &#8220;C:local\\path\\error.log&#8221;<\/p>\n<p><strong>4.14?? LogLevel\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u8bbe\u7f6e\u4e00\u822c\u7684\u9519\u8bef\u7684\u65e5\u5fd7\u7ea7\u522b<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>LogLevel?<em>Level<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4<\/td>\n<td>LogLevel?<em>warn<\/em><\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u8bbe\u7f6e\u4e00\u822c\u65e5\u5fd7\u7684\u8f93\u51fa\u957f\u5ea6\uff0c\u8ddf\u5b83\u7684\u91cd\u5199\u8fc7\u7a0b\u65e0\u5173\u3002\u8fd9\u91cc\u6709\u4e00\u4e2alevel\u7684\u53ef\u7528\u503c\u5217\u8868\uff1aemerg\u3001alert\u3001crit\u3001error\u3001warm\u3001notice\u3001info\u3001debug\u3002\u5f53\u524d\u7684ISAPI_Rewrite\u65e5\u5fd7\u53ea\u8bb0\u5f55\u9519\u8bef\u4fe1\u606f\u3002<br \/>\n\u8bbe\u7f6eLogLevel\u8c03\u8bd5\u6765\u89e3\u51b3\u914d\u7f6e\u6587\u4ef6\u4e2d\u52a0\u8f7d\u7684\u95ee\u9898\u3002<\/p>\n<p><strong>4.15??\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u628a\u5e94\u7528\u4e8e\u7279\u5b9aIP\u5730\u6216\u8005\u4e3b\u673a\u7684\u6307\u4ee4\u7f16\u7ec4<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>&lt;VirtualHost addr[:port] [addr[:port]] &#8230;&gt; &#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8230;?\u6807\u7b7e\u7528\u6765\u5bf9\u5e94\u7528\u5230\u7279\u5b9a\u865a\u62df\u4e3b\u673a\u91cc\u7684\u6307\u4ee4\u8fdb\u884c\u5206\u7ec4\u3002<br \/>\n<em>addr<\/em>\u7684\u53ef\u7528\u503c\u4e3a\uff1a<br \/>\n? \u7279\u5b9a\u7684IP\u5730\u5740<br \/>\n? \u5b8c\u6574\u7684\u57df\u540d<br \/>\n? \u5b57\u7b26&#8217;*&#8217;\u53ef\u4ee5\u5339\u914d\u4efb\u4f55\u4e3b\u673a\u6216\u8005\u7279\u5b9a\u670d\u52a1\u5668\u7684\u4efb\u4f55\u7aef\u53e3\u53f7\u3002<br \/>\n\u4f8b\u5982\uff1a<\/p>\n<pre>RewriteEngine offAllowOverride none&lt;VirtualHost onesite.com www.onesite.com&gt;RewriteEngine onAllowOverride all<\/pre>\n<p>\u4e0d\u8981\u5fd8\u4e86\u5728\u6bcf\u4e2a\u6807\u7b7e\u4e2d\u5305\u542b<em><strong>RewriteEngine on<\/strong><\/em>\u6307\u4ee4\uff0c\u4e5f\u4e0d\u8981\u5c06\u4e0d\u80fd\u5e94\u7528\u7684\u89c4\u5219\u5c01\u88c5\u8fdb\u53bb\u3002<\/p>\n<p><strong>4.16?\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u5c06\u9002\u7528\u4e8e\u7279\u5b9a\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u76ee\u5f55\u548c\u5b50\u76ee\u5f55\u7684\u6307\u4ee4\u7f16\u7ec4<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>&#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8230;?\u6807\u7b7e\u88ab\u7528\u6765\u5bf9\u5e94\u7528\u5230\u7279\u5b9a\u6587\u4ef6\u7cfb\u7edf\u76ee\u5f55\u4ee5\u53ca\u5b50\u76ee\u5f55\u7684\u6307\u4ee4\u8fdb\u884c\u5206\u7ec4\u3002\u901a\u914d\u7b26?\u548c*\u662f\u53ef\u7528\u7684\u3002\u6b63\u5219\u8868\u8fbe\u5f0f\u4e5f\u662f\u53ef\u7528\u7684\uff0c\u9700\u8981\u4ee5~\u5b57\u7b26\u6253\u5934\u3002<br \/>\n\u5bf9\u76ee\u5f55\u8def\u5f84\u53c2\u6570\u5fc5\u987b\u5c0f\u5fc3\uff1a\u5b83\u4eec\u5fc5\u987b\u5b57\u9762\u5339\u914d\u7528\u6765\u8bbf\u95ee\u6587\u4ef6\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u7528\u4e8e\u67d0\u4e00\u7279\u5b9a\u7684\u6307\u4ee4\u5e76\u4e0d\u9002\u7528\u4e8e\u6765\u81ea\u540c\u4e00\u76ee\u5f55\u4e0b\u901a\u8fc7\u4e0d\u540c\u7684\u8def\u5f84\u7684\u6587\u4ef6\u8bbf\u95ee\uff0c\u4f8b\u5982\u901a\u8fc7\u4e0d\u540c\u7684\u7b26\u53f7\u94fe\u63a5\u3002\u53ea\u6709\u5b8c\u6574\u7684\u6587\u4ef6\u8def\u5f84\u662f\u88ab\u5141\u8bb8\u4f7f\u7528\u7684\u3002<br \/>\n\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;Directory C:\/inetpub\/&gt;  AllowOverride None&lt;Directory C:\/inetpub\/home\/&gt;  AllowOverride FileInfo&lt;Directory ~ \"C:\/inetpub\/wwwroot\/.*\/[0-9]{3}\"&gt;  # ... directives here ...<\/pre>\n<p>\u4e0d\u8981\u5fd8\u4e86\u5728\u6bcf\u4e2a\u6807\u7b7e\u4e2d\u5305\u542b<em><strong>RewriteEngine on<\/strong><\/em>\u6307\u4ee4\uff0c\u4e5f\u4e0d\u8981\u5c06\u4e0d\u80fd\u5e94\u7528\u7684\u89c4\u5219\u5c01\u88c5\u8fdb\u53bb\u3002<\/p>\n<p><strong>4.17\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u5c06\u9002\u7528\u4e8e\u7279\u5b9a\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u76ee\u5f55\u548c\u5b50\u76ee\u5f55\u7684\u6307\u4ee4\u7f16\u7ec4<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>&#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8230;?\u88ab\u7528\u6765\u5c01\u88c5\u4e00\u4e2a\u53ea\u9002\u7528\u4e8e\u6307\u5b9a\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u76ee\u5f55\u548c\u5b50\u76ee\u5f55\u7684\u6307\u4ee4\u7ec4\u3002\u8fd9\u4e2a\u6307\u4ee4\u548c&lt;Directory ~&gt; \u8bed\u6cd5\u76f8\u540c\u3002<br \/>\n\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;DirectoryMatch \"^\/www\/(.+\/)?[0-9]{3}\"&gt;   # ... directives here ...<\/pre>\n<p>\u4e0d\u8981\u5fd8\u4e86\u5728\u6bcf\u4e2a&lt; DirectoryMatch&gt;\u6807\u7b7e\u4e2d\u5305\u542b?<strong><em>RewriteEngine on<\/em><\/strong>\u6307\u4ee4\uff0c\u4e5f\u4e0d\u8981\u5c06\u4e0d\u80fd\u5e94\u7528\u7684\u89c4\u5219\u5c01\u88c5\u8fdb\u53bb\u3002<\/p>\n<p><strong>4.18?\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u5c06\u5e94\u7528\u4e8e\u5339\u914d\u6587\u4ef6\u540d\u7684\u6307\u4ee4\u5305\u88c5\u8d77\u6765<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>&lt;Files?<em>filename<\/em>&gt; &#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6307\u4ee4\u4ee5\u6587\u4ef6\u540d\u9650\u5b9a\u4e86\u5c01\u88c5\u7684\u6307\u4ee4\u7684\u4f5c\u7528\u57df\u3002<em>filename<\/em>\u53c2\u6570\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6587\u4ef6\u540d\uff0c\u652f\u6301?\u548c*\u4ee5\u53ca\u4ee5~\u5b57\u7b26\u6253\u5934\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<br \/>\n\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;Files index.*&gt;   # ... directives here ... &lt;Files ~ \"\\.(gif|jpe?g|png)$\"&gt;   # ... directives here ...<\/pre>\n<p>\u4e0d\u8981\u5fd8\u4e86\u5728\u6bcf\u4e2a\u6807\u7b7e\u4e2d\u5305\u542b<em><strong>RewriteEngine on<\/strong><\/em>\u6307\u4ee4\uff0c\u4e5f\u4e0d\u8981\u5c06\u4e0d\u80fd\u5e94\u7528\u7684\u89c4\u5219\u5c01\u88c5\u8fdb\u53bb\u3002<\/p>\n<p><strong>4.19??\u6307\u4ee4<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>\u8bf4\u660e<\/td>\n<td>\u5c06\u5e94\u7528\u4e8e\u5339\u914d\u6587\u4ef6\u540d\u7684\u6307\u4ee4\u5305\u88c5\u8d77\u6765<\/td>\n<\/tr>\n<tr>\n<td>\u8bed\u6cd5<\/td>\n<td>&lt;FilesMatch?<em>regex<\/em>&gt; &#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u73af\u5883<\/td>\n<td>server config, virtual host, directory, .htaccess<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6307\u4ee4\u7684\u8bed\u6cd5\u548c_\u6307\u4ee4&#8221;&gt;&lt;Files ~&gt;\u8bed\u6cd5\u5b8c\u5168\u4e00\u6837\u3002<\/p>\n<pre>&lt;FilesMatch \"\\.(gif|jpe?g|png)$\"&gt;<\/pre>\n<p>\u4e0d\u8981\u5fd8\u4e86\u5728\u6bcf\u4e2a\u6807\u7b7e\u4e2d\u5305\u542b<em><strong>RewriteEngine on<\/strong><\/em>\u6307\u4ee4\uff0c\u4e5f\u4e0d\u8981\u5c06\u4e0d\u80fd\u5e94\u7528\u7684\u89c4\u5219\u5c01\u88c5\u8fdb\u53bb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ISAPI_Rewrite3\u4f7f\u7528\u6559\u7a0b(\u4e8c) \u63d2\u5165\u6210\u4efd \u63d2\u5165\u6210\u5206\u6709\u4e24\u4e2a\u7528\u5904\u2015\u2015\u628a\u9879\u76ee\u7f16\u7ec4\u5230\u5b50\u8868\u8fbe\u5f0f\u4e2d\uff0c\u5e76\u4e14\u5bf9\u751f\u6210\u2026 <span class=\"read-more\"><a href=\"https:\/\/web.jofar.cn\/?p=254\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,12,5],"tags":[],"class_list":["post-254","post","type-post","status-publish","format-standard","hentry","category-cloud","category-server","category-practice-readme"],"_links":{"self":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/posts\/254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=254"}],"version-history":[{"count":0,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/posts\/254\/revisions"}],"wp:attachment":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}