繁体   English   中英

如何在正则表达式中使用ProxyMatch或ProxyPassMatch来映射多个上下文路径

[英]How to Use ProxyMatch or ProxyPassMatch with Regex for mapping multiple Context paths

我正在使用基于Apache Web服务器版本2.2.4构建的IBM IHS Web服务器。

我的要求是使用匹配中的正则表达式代理传递各种Context路径。

我尝试使用ProxyPassMatch但出现以下错误

错误:“无效的ProxyPass | ProxyPassMatch参数。参数的格式必须为'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>

请告知如何实现。

问候Sridhar

如果将ProxyPassMatch放在LocationMatch部分的旁边,则必须省略 ProxyPassMatch(regex)的第一个参数。 它将来自LocationMatch。 我的( 工作 )配置中的示例:

<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>

否则,您会收到错误消息

错误:“无效的ProxyPass | ProxyPassMatch参数。参数的格式必须为'key = value'”

它记录在这里: https : //httpd.apache.org/docs/trunk/mod/mod_proxy.html#proxypass

始终使用单独的行进行注释,并引用字符串参数。 在他们的bugzila中有bug记录了这个问题,但是我相信您没有使用旧版本。 https://bz.apache.org/bugzilla/show_bug.cgi?id=40439

<LocationMatch "^/(ae/en|ar/en|ar/es|at/en|au/en|be/en|br/en)/">
Order Allow,Deny
Allow from all
#should keep varying as per the regex matched in location match
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/" 
</LocationMatch>

错误:“无效的ProxyPass | ProxyPassMatch参数。参数的格式必须为'key = value'”

如果您在代理指令的末尾使用了RewriteUrl标志,则可能会发生这种情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM