Apache LocationMatch matching urls starting with…

て烟熏妆下的殇ゞ 提交于 2021-01-28 19:57:42

问题


I'm using apache to redirect AJAX request to server backend in my AJAX app.

Everything that starts with /service/ should go to service backend:

<LocationMatch "/service">
    ProxyPass http://backend:8080/service Keepalive=On
    Header set Cache-Control "no-cache, no-store, must-revalidate"
</LocationMatch>

Everything that starts with /auth goes to authentication server:

<LocationMatch "/auth">
    ProxyPass http://keycloak:8090/auth/ Keepalive=On
</LocationMatch>

I was happy with my apparently working solution, unless the auth channel was added to backend, and them I've noticed, that requests to /service/auth/info are not consumed by backend, but land in authentication server.

Apparently I have some understanding problem. How should I match URLs that start with given string, and not contain it somewhere in the middle?


回答1:


Use the caret (^) to indicate the beginning of the string:

<LocationMatch "^/service">


来源:https://stackoverflow.com/questions/51560733/apache-locationmatch-matching-urls-starting-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!