URL_Rewrite的软件ISAPI_Rewrite

来源:互联网 发布:老男孩教育大数据 编辑:程序博客网 时间:2024/05/16 13:49
URL重写可以把动态页面变成静态页面(搜索引擎优化),当然还有其他作用,譬如将外部访问mdb数据库文件的页面重写到指向404页面等等.
"Apache的mod_rewrite是提供了强大URL操作的杀手级的模块,可以实现几乎所有你梦想的URL操作类型,其代价是你必须接受其复杂性,因为mod_rewrite的主要障碍就是初学者不容易理解和运用,即使是Apache专家有时也会发掘出mod_rewrite的新用途。"有兴趣的朋友可以参考APACHE的URL重写指南部分和Apache模块 mod_rewrite
IIS下也有实现Apache的mod_rewrite模块功能的组件,ISAPI_Rewrite就是其中之一.

ISAPI_Rewrite的下载地址是:http://www.helicontech.com/download/#isapi_rewrite
我的网络硬盘上也有下soft目录中isapi_rewrite lite_x86_0061.rar
其中有个免费版本ISAPI_Rewrite Lite.
lite版本不支持虚拟站点配置,proxiing,元数据监测和自动缓存清理。
This is simplified edition of ISAPI_Rewrite. It does not support per-virtual-site configurations, proxiing, metabase monitoring and automatic cache cleanup but all other features are supported. ISAPI_Rewrite Lite is completely FREE! It may be an ideal solution for the server hosting the only site, development or testing purposes.
metabase元数据:metabase 元数据库 指一个驻留内存的数据存储区域,其中存放着IIS的配置值./Metabase是储存成System32/Inetsrv资料夹中的Metabase.bin文件

免费版只有自动安装的,安装后打开安装文件夹,里面help文件详细的说明了该组件的使用方法.
去掉http.ini的只读属性,修改该文件即可对映射规则进行添加/修改
基本用法:
将/test/re.asp?id=123映射到/test/re/123
RewriteRule /test/re/(/d+) /test/re.asp/?id=$1

好东西,还得慢慢学习~

Syntax: RewriteRule Pattern FormatString [Flags]  

The RewriteRule directive is the real rewriting workhorse. The directive can occur more than once. Each directive defines one single rewriting rule. The definition order of these rules is important, because this order is used when applying the rules at run-time.

  • Pattern

    Specifies regular expression that will be matched against Request-URI. See regular expression syntax section for more information.

  • FormatString

    Specifies format string that will generate new URI. See format string syntax section for more information.

  • [Flags]

    Flags is a comma-separated list of the following flags:

    • I (ignore case)

      Indicates that characters are matched regardless of a case. This flag affects RewriteRule directive and all corresponding RewriteCond directives.

    • F (Forbidden)

      Stops the rewriting process and sends 403 Forbidden response to a client. Note that FormatString is useless in this case and could be set to any non-empty string.

    • L (last rule)

      Stop the rewriting process here and don't apply any more rewriting rules. Use this flag to prevent the currently rewritten URI from being rewritten further by following rules.

    • N (Next iteration)

      Forces rewriting engine to modify rule's target and restart rules checking from the beginning (all modifications are saved). Number of restarts is limited by the value specified in the RepeatLimit directive. If this number is exceeded N flag will be simply ignored.

    • NS (Next iteration of the same rule)

      Works like the N flag but restarts rules processing from the same rule (i.e. forces repeat of the rule application). Maximum number of single rule iterations is given by the RepeatLimit directive. But a number of single rule repeats does not count for the global number of repeats (i.e. repeats limit for a number of iterations caused by N flag is independent of a number of repeats caused by NS).

    • P (force proxy)

      Forces the result URI to be internally forced as a proxy request and immediately (i.e., rewriting rule processing stops here) put through the ISAPI extension that handles proxy requests. You have to make sure that the substitution string is a valid URI including protocol, host etc. or proxy will return an error.

    • R (explicit redirect)

      Force server to send immediate response to client with redirect instruction, providing result URI as a new location. Redirect rule is always the last rule.

    • RP (permanent redirect)

      Almost the same as the [R] flag but issues 301 (moved permanently) HTTP status code instead of 302 (moved temporary).

    • U (Unmangle Log)

      Log the URL as it was originally requested and not as the URL was rewritten.

    • O (nOrmalize)

      Normalizes string before processing. Normalization includes removing of an URL-encoding, illegal characters, etc. Also, IIS normalization of an URI completely removes query string. So, normalization should not be used if query string is needed. This flag is useful with URLs and URL-encoded headers.

    • CL (Case Lower)

      Changes case of a format result to lower.

    • CU (Case Upper)

      Changes case of a format result to upper.

原创粉丝点击