我正在使用构建在 Apache Web 服务器版本 2.2.4 之上的 IBM 的 IHS Webserver。
我的要求是在匹配中使用正则表达式代理传递各种上下文路径。
我尝试使用 ProxyPassMatch
但出现以下错误
ERROR: "Invalid ProxyPass|ProxyPassMatch parameter. Parameter must be in the form 'key=value'"
<LocationMatch "^/(ae/en|ar/en|ar/es|at/en|au/en|be/en|br/en)/">
Order Allow,Deny
Allow from all
ProxyPass http://www.xyz.com.au:80/au/en/ #(should keep varying as per the regex matched in location match )
ProxyReverse http://www.xyz.com.au:80/au/en/ #(should keep varying as per the regex matched in location match )
</LocationMatch>
请告知如何实现这一点。
问候 斯里达尔
最佳答案
如果您将 ProxyPassMatch 放在 LocationMatch 部分,则 ProxyPassMatch(正则表达式)的第一个参数必须省略。它将来自 LocationMatch。我的 ( working ) 配置示例:
<VirtualHost *:80>
ServerName gopal.lv
ServerAlias gopal.lv www.gopal.lv
ProxyPreserveHost On
<LocationMatch "^/(img|js|css|att|thumb|banner)/(.+)$">
#Note: only 1 argument here
ProxyPassMatch "http://192.168.1.11/$1/$2"
</LocationMatch>
#Note we have 2 arguments here
ProxyPassMatch "^/(img|js|css|att|thumb|banner)/(.+)$" "http://192.168.1.11/$1/$2"
ProxyPass / http://192.168.1.12/
</VirtualHost>
否则会报错
ERROR: "Invalid ProxyPass|ProxyPassMatch parameter. Parameter must be in the form 'key=value'"
在此处记录:https://httpd.apache.org/docs/trunk/mod/mod_proxy.html#proxypass
关于regex - 如何使用 ProxyMatch 或 ProxyPassMatch 与 Regex 映射多个上下文路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33885831/