In Apache config file, there are some rules defines like below:
<IfModule mod_rewrite.c>
RewriteRule ^(Category)/([^/]+)/(.+)$ index.php?module=$1&id=$2&action=$3 [B,L,QSA]
RewriteRule ^(Listing)/(.+)$ index.php?module=$1&id=$2 [B,L,QSA]
RewriteRule ^([^/]+)/(.+)$ index.php?module=$1&action=$2 [B,L,QSA]
...
</IfModule>
All this address http://web/foo/bar
is internally translated (no redirects) into http://web/index.php?module=foo&id=bar
: foo
, bar
are fed to index.php as params.
Now I want to add a rule which translates http://web/api?key1=val1&key2=val2
to http://web/api/index.php?key1=val1&key2=val2
in a similar manner.
I tried placing RewriteRule ^(api)//?(.+)$ api/index.php?$2 [B,L,QSA]
at top of all rules, restarted apache but http://web/api?foo=bar
becomes http://web/api/?foo=bar
(with extra /
after api
) in browser's address bar and the call is redirected to http://web/index.php
(as it throws error from the file).
How to change the RewriteRule to render http://web/api/index.php
when request is made http://web/api?..
?