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,因此一定要注意避免引起重写转发死循环。

     

     

  • 相关阅读:
    Java数据库小项目02--管家婆项目
    Java数据库小项目01--实现用户登录注册
    Java数据库小项目00---基础知识
    MySQL基础练习02---牛客网
    ICMP
    语法糖
    双绞线
    telnet 时代的 bbs
    ARPA
    IEEE802是一个局域网标准系列
  • 原文地址:https://www.cnblogs.com/xinglongbing/p/2456887.html
Copyright © 2011-2022 走看看