【问题标题】:Apache rewriterule with proxyPass and proxyPassReverse使用 proxyPass 和 proxyPassReverse 的 Apache 重写
【发布时间】:2013-03-02 10:48:04
【问题描述】:

我需要将以下重写规则与 proxyPass 和 proxyPassReverse 一起使用

RewriteEngine On
RewriteRule  ^(market|stock|mutual)$ stackoverflow/$1 [L]

我的虚拟主机定义是

<VirtualHost *>
    ServerName localhost
    ProxyPass / http://localhost:8080/ 
    ProxyPassReverse / http://localhost:8080/  
</VirtualHost>

我应该在哪里插入重写规则,以便当我点击 URL -- localhost/market 时,它将对 localhost:8080/stackoverflow/market 执行内部重写

请帮忙

【问题讨论】:

    标签: apache mod-rewrite rewrite httpd.conf proxypass


    【解决方案1】:

    知道了

    <VirtualHost *>
        ServerName localhost
        ProxyPass / http://localhost:8080/stackoverflow/ 
        ProxyPassReverse / http://localhost:8080/stackoverflow/ 
        RewriteEngine On
        RewriteRule  ^(market|stock|mutual)$ stackoverflow/$1 [L]
    </VirtualHost>
    

    【讨论】:

    • 您能帮我理解为什么在这种情况下将RewriteRule 放在&lt;Directory&gt; 部分没有效果吗?是不是因为ProxyPass先生效,其他指令都没有应用?
    • iX3,你是对的。 ProxyPass 优先于 mod_rewrite 和 mod_alias。
    猜你喜欢
    • 1970-01-01
    • 2012-10-07
    • 2012-10-06
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2018-06-21
    • 2013-07-01
    相关资源
    最近更新 更多