Apache RewriteRule

http.conf

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule ^/ptest01/(.*) http://192.168.0.8:7001/ptest01/$1 [R,L]
RewriteRule ^/ptest02/(.*) http://192.168.0.8:7009/ptest02/$1 [R,L]

访问:

http:/localhost/ptest01/index.jsp 跳转到  http://192.168.0.8:7001/ptest01/index.jsp

http:/localhost/ptest02/index.jsp 跳转到  http://192.168.0.8:7009/ptest02/index.jsp

如果不进行URL跳转则配置如下:

RewriteRule ^/ptest01/(.*) http://192.168.0.8:7001/ptest01/$1 [P,L]
RewriteRule ^/ptest02/(.*) http://192.168.0.8:7009/ptest02/$1 [P,L]

 'proxy|P'(强制为代理)
此标记使替换成分被内部地强制作为代理请求发送,并立即中断重写处理,然后把处理移交给mod_proxy模块。你必须确保此替换串是一个能够被mod_proxy处理的有效URI(比如以http://hostname开头),否则将得到一个代理模块返回的错误。使用这个标记,可以把某些远程成分映射到本地服务器域名空间,从而增强了ProxyPass指令的功能。 
注意:要使用这个功能,必须已经启用了mod_proxy模块。

原文地址:https://www.cnblogs.com/yshyee/p/7210784.html