【问题标题】:mod_rewrite rule not taking effectmod_rewrite 规则未生效
【发布时间】: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


    【解决方案1】:

    尝试:

    # after : this rule is not taking effect, THE URL is going to proxypassmatch
    RewriteCond %{QUERY_STRING} fname=
    RewriteRule !^/?v1/documents/?$ /v1/documents [QSA,R,L]
    RewriteRule ^/?v1/documents - [L] 
    

    【讨论】:

    • 更改 RewriteRule 中的测试或添加其他查询 strinf 标志测试。我用第一个编辑我的答案。
    • 不工作,错误消失了,但现在又回到了我原来的问题。它要去proxypassmatch
    • 你加了我的 2 RewriteRule ?
    猜你喜欢
    • 1970-01-01
    • 2011-12-27
    • 2012-07-23
    • 1970-01-01
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多