I'm trying to run two different php frameworks on the same server. The framework to use is determined by the first path in the uri.
So for example:
will go to the index.php located in:
/var/www/html/api/api
And everything else (http://www.example.com/v2/requestname) will go to the index.php located in:
/var/www/html/api2/public
Here is my apache 2.2 config:
Alias /v1 /var/www/html/api/api
<Directory /var/www/html/api/api>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</Directory>
DocumentRoot "/var/www/html/api2/public"
<Directory "/var/www/html/api2/public">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</Directory>
I've been attempting to do this with apache, but every request is being routed to api2. Everything I'm looking seems to say this should work.
So here's the solution I came up with for anyone in the future:
Set anything beginning with /v1 to be send to the first version of the API.
Alias /v1 /var/www/html/api/api/index.php
Send everything else to the second version:
DocumentRoot "/var/www/html/api2/public"
<Directory "/var/www/html/api2/public">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</Directory>
The trick was adding index.php onto the end of the Alias.