php - Mod Rewrite faux-directory path with extra query string -
i'm trying write rewrite rule in .htaccess file has following behavior. i'm doing api located @ real location in form of:
https://www.domain.com/apifolder/entry.php?call=testcall&data=testdata
the api call routed starting entry.php , delivers appropriate response. entire api lands upon large switch statement of valid api calls. problem is, url not nice. i'm trying replace url of form:
https://www.domain.com/api/testcall?data=testdata
i have gotten close following rewrite rule:
rewriterule ^api/([^/]+)/? /apifolder/entry.php?call=$1 [l]
however, desired example above not work, because there first parameter seems coming in (data, in reality second parameter), led ?. if try url:
https://www.domain.com/api/testcall&data=testdata
where it's led & instead, works fine. looks weird me too, sadly. there can let rewritten url take in query string beginning ? instead?
i managed solve including [qsa] flag in rule, passes query string (in desirable format) real url:
rewriterule ^api/([^/]+)/? /apifolder/entry.php?call=$1 [qsa,l]
i tried after seeing stackoverflow answer: match question mark in mod_rewrite rule regex
Comments
Post a Comment