zoukankan      html  css  js  c++  java
  • Apache 虚拟主机和Url重写

    1.虚拟主机

    http://httpd.apache.org/docs/2.2/vhosts/details.html
     

    2.Url重写:

    http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html 

    http://httpd.apache.org/docs/2.2/rewrite/proxy.html 

    http://httpd.apache.org/docs/2.2/rewrite/avoid.html

    3.RewriteRule

    http://httpd.apache.org/docs/2.2/rewrite/flags.html
    RewriteRule指令说明:

    The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl, or the break command in C. Use this flag to indicate that the current rule should be applied immediately without considering further rules.
    应用L标志,重写Url一旦匹配不会进一步对后面的规则进行匹配处理。

    Use of the [P] flag causes the request to be handled by mod_proxy, and handled via a proxy request. For example, if you wanted all image requests to be handled by a back-end image server, you might do something like the following:
    RewriteRule /(.*)\.(jpg|gif|png) http://images.example.com/$1.$2 [P]

    Use of the [P] flag implies [L] - that is, the request is immediately pushed through the proxy, and any following rules will not be considered.

    You must make sure that the substitution string is a valid URI (typically starting with http://hostname) which can be handled by the mod_proxy. If not, you will get an error from the proxy module. Use this flag to achieve a more powerful implementation of the ProxyPass directive, to map remote content into the namespace of the local server.

    Security Warning

    Take care when constructing the target URL of the rule, considering the security impact from allowing the client influence over the set of URLs to which your server will act as a proxy. Ensure that the scheme and hostname part of the URL is either fixed, or does not allow the client undue influence.

    代理转发的请求后面会继续经过Apache再次Rewrite,因此一定要注意避免引起重写转发死循环。

     

     

  • 相关阅读:
    GIT和SVN之间的五个基本区别
    nolock的使用
    Net线程足迹 传递参数至线程
    .NET中的三种Timer的区别和用法(转)
    探索并发编程(六)------Java多线程性能优化
    探索并发编程(七)------分布式环境中并发问题
    Lock与synchronized 的区别
    常用EXE文件反编译工具
    Socket原理
    开源的力量(随时更新)
  • 原文地址:https://www.cnblogs.com/xinglongbing/p/2456887.html
Copyright © 2011-2022 走看看