Apache ProxyPass映射工作,重写规则不起作用

时间:2012-02-23 14:14:24

标签: apache rewrite proxypass

我将这些行放入Apache 2.2的httpd.conf文件中:

ProxyPass        /api/post    http://localhost:8082/DE_API/post
ProxyPassReverse /api/post    http://localhost:8082/DE_API/post
RewriteRule      /api/upload  /api/post

然后正确映射以下请求:

http://mydomain.com/api/post

这个不起作用:

http://mydomain.com/api/upload

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

变化:

RewriteRule      /api/upload  /api/post

RewriteRule      ^api/upload  /api/post [L,NC]

来自:RewriteRule Directive Apache docs

  

在Directory和htaccess上下文中,在删除将服务器引导到当前RewriteRule的前缀(例如“app1 / index.html”或“index.html”取决于where)之后,Pattern将首先与文件系统路径匹配。指令已定义。)

因此,在/匹配时,请勿使用RewriteRule启动模式。