Apache 学习笔记 - Apache mod_rewrite

http://httpd.apache.org/docs/2.4/en/rewrite/

mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules. This allows you to map arbitrary URLs onto your internal URL structure in any way you like.

mod_rewrite提供了一种基于正则表达式规则动态修改传入URL请求的方法。 这允许您以任何喜欢的方式将任意URL映射到您的内部URL结构。

It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests: server variables, environment variables, HTTP headers, time stamps, external database lookups, and various other external programs or handlers, can be used to achieve granular URL matching.

它支持无限数量的规则,并为每个规则提供无限数量的附加规则条件,以提供真正灵活和强大的URL操作机制。URL操作可以依赖于各种测试:服务器变量,环境变量,HTTP头,时间戳,外部数据库查找以及各种其他外部程序或处理程序,可用于实现精细的URL匹配。

Rewrite rules can operate on the full URLs, including the path-info and query string portions, and may be used in per-server context (httpd.conf), per-virtualhost context (<VirtualHost> blocks), or per-directory context (.htaccess files and <Directory> blocks). The rewritten result can lead to further rules, internal sub-processing, external request redirection, or proxy passthrough, depending on what flags you attach to the rules.

重写规则可以对完整的URL进行操作,包括路径信息和查询字符串部分,并可用于每个服务器上下文(httpd.conf),每个虚拟主机上下文(<VirtualHost>块)或每个目录上下文(.htaccess文件和<Directory>块)。重写的结果可能导致进一步的规则,内部子处理,外部请求重定向或代理直通,具体取决于您附加到规则的标志。

Since mod_rewrite is so powerful, it can indeed be rather complex. This document supplements the reference documentation, and attempts to allay some of that complexity, and provide highly annotated examples of common scenarios that you may handle with mod_rewrite. But we also attempt to show you when you should not use mod_rewrite, and use other standard Apache features instead, thus avoiding this unnecessary complexity.

由于mod_rewrite非常强大,它确实可能相当复杂。本文档对参考文档进行了补充,并试图消除其中的一些复杂性,并提供可以使用mod_rewrite处理的常见场景的高度注释的示例。但是我们也试图告诉你什么时候不应该使用mod_rewrite,而是使用其他标准的Apache特性来避免这种不必要的复杂性。

  1. mod_rewrite参考文档 (mod_rewrite reference documentation)
  2. 正则表达式和mod_rewrite简介(Introduction to regular expressions and mod_rewrite)
  3. 使用mod_rewrite进行URL重定向和重新映射(Using mod_rewrite for redirection and remapping of URLs)
  4. 使用mod_rewrite来控制访问(Using mod_rewrite to control access)
  5. 动态虚拟主机与mod_rewrite(Dynamic virtual hosts with mod_rewrite)
  6. 使用mod_rewrite进行动态代理(Dynamic proxying with mod_rewrite)
  7. 使用RewriteMap(Using RewriteMap)
  8. 先进的技术(Advanced techniques)
  9. 何时不使用mod_rewrite(When NOT to use mod_rewrite)
  10. 重写规则标志(RewriteRule Flags)
  11. 技术细节(Technical details)

猜你喜欢

转载自blog.csdn.net/u013725455/article/details/80855979