I have the following configuration in my httpd.conf
:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:/opt/Apache24/htdocs"
RewriteEngine on
RewriteCond "c:/opt/Apache24/htdocs/application1/v1/$1" !-f
RewriteRule "^/(.*)" "http://host1.com.br/application1/v1/$1" [P]
RewriteCond "c:/opt/Apache24/htdocs/$1" !-f
RewriteRule "^/(.*)" "http://host2.com.br/$1" [P]
</VirtualHost>
(The names application1
, host1
and host2
are illustrative)
The purpose of this configuration is to check if there are mocks for the services of host1
and host2
, if it exists, mocks are used, if it does not exist, a redirect is made to the server with the application.
The problem is that there is no way to get to the second step (second condition occurs) because if apache does not find the file in the first condition because it is being searched in the wrong folder (folder: ... / application1 / v1 / ...) or if mock does not exist, it will redirect to the address http://host1.com.br/application1/v1/...
, which falls, causing the second condition to never be true.
Does anyone know how to RewriteCond
to check if the initial part of path corresponds to /application1/v1/
?