【发布时间】:2016-01-26 07:29:52
【问题描述】:
我的应用程序有以下 apache 配置,我想设置一个规则,这样当 URL 包含 fname 参数时,它应该重写为 /v1/documents 以及 url 中的所有查询参数。在所有其他情况下,它应该与查询参数一起重写为http://localhost:8003/v1/documents。请帮忙。
ProxyRequests Off
ProxyPreserveHost On
Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore
RewriteEngine ON
# for old bugtrack style url compatibility
RewriteRule ^/(.\d+)$ /goto/$1 [R]
# to handle /v1/ routes containing uri in old bugtrack
RewriteCond %{QUERY_STRING} uri=(other-document/.*)$
RewriteRule ^/v1/documents http://localhost:9000/download.xqy?file=%1 [P]
RewriteCond %{QUERY_STRING} bn=(.\d+)$
RewriteRule ^/bug-details\.xqy$ /goto/%1? [R,L]
#########################
this rule is not taking effect, THE URL is going to proxypassmatch
RewriteCond %{QUERY_STRING} !fname=
RewriteRule ^/v1/documents /v1/documents [QSA,R,L]
########################
ProxyPassMatch /v1/.*$ http://localhost:8003
ProxyPass / http://localhost:9050/ retry=1 acquire=3000 timeout=2400 Keepalive=On
ProxyPassReverse / http://localhost:9050/
【问题讨论】:
标签: apache .htaccess mod-rewrite