I want every call with
http://localhost/api/
(like the root folder ), e.g. http://localhost/api/get/users is actually http://localhost/api/index.php?handler=get/users .
http://localhost/api/get/user/87 should be http://localhost/api/index.php?handler=get/user/87 , where in index.php I would catch the variable $ _GET handler and process it properly.
If I have such rewriting rules, it only works for one
RewriteRule ^([^/\.]+)/?$ index.php?handler=$1 [QSA,L]
two
RewriteRule ^([^/\.]+)/?$ index.php?handler=$1 [QSA,L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?handler=$1&handler2=$2 [QSA,L]
three slashes, etc.
RewriteRule ^([^/\.]+)/?$ index.php?handler=$1 [QSA,L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?handler=$1&handler2=$2 [QSA,L] RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?handler=$1&handler2=$2&handler3=$3 [QSA,L]
So, for the first case, http://localhost/api/a will work, but http://localhost/api/a/b will result in a Not Found error.
EDIT . Should it be good?
RewriteRule ^(.*)$ index.php?handler=$1 [L,QSA]
source share