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

     

     

  • 相关阅读:
    【Docker】 CentOS7 安装 Docker 及其使用方法 ( 一 )
    js加密解密
    JSON.parse和eval()的区别
    复选框(全选/全不选/反选)
    圆形进度条
    C# JToken类,实现解析动态json数据、遍历、查找
    使IIS服务器支持下载 apk/ipa 安装包
    Python关键字
    C#泛型(二)泛型类
    C#泛型(一)泛型方法
  • 原文地址:https://www.cnblogs.com/xinglongbing/p/2456887.html
Copyright © 2011-2022 走看看