I have these rewriteRules which work fine:
# 4 params
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?app=$1&do=$2&what=$3&id=$4 [NC,L,QSA]
# 3 params
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?app=$1&do=$2&what=$3 [NC,L,QSA]
# 2 params
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?app=$1&do=$2 [NC,L,QSA]
# 1 param
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?app=$1 [NC,L,QSA]
Now, i would like that if the url contains /api/
then i would like it to point to a file called public.api.php
but still have those 4 query vars as parameters.
I could arrange that via explicitating all the rules in the order in which they should be processed, but it makes for a quite lengthy .htaccess file.
My questions is this: is there a way to add some sort of conditional rule that would check if /api/
is in the requested uri and according to this, point to index.php
or public.api.php
without repeating the processing of the four query vars?