Currently my .htaccess
looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [QSA]
All URIs are passed to the PHP script which then parses it and returns stuff.
Now I want to implement a versioning system, in which there would be different script handling the URIs depending on the version called.
That is:
- if I call
/v1/countries/es/users
, I want to pass the URI/countries/es/users
to the scriptv1.php
- if I call
/v2/users/314/settings
, then I want the URI/users/314/settings
passed to the scriptv2.php
I tried doing something like
RewriteRule ^/?v(\d)/.*$ v$1.php [QSA]
That would send execution to the version-specific script, but I still want to strip out the /v1/
initial part of the URI when passed to the script, i.e., I want the script to receive the URI without the initial version part.
How can I achieve that?