#What does this mean??
RewriteRule ^(.+)$ quizAPI.php?url=$1 [QSA,L]
Not quite sure of the difference between Apache and LiteSpeed in this respect (perhaps a difference in how the request is mapped to the filesystem?), however, this is only working on Apache arguably by "chance". The reason being, when you request /users/get/
the above rewrites as follows:
- Request
/user/get/
- Rewrite (1st pass) to
quizAPI.php?url=user/get/
- Rewrite process then starts over (due to the
L
flag)
- Rewrite (2nd pass) to
quizAPI.php?url=quizAPI.php&url=user/get/
(due to the QSA
flag)
- Rewrite process then starts over (due to the
L
flag)
- Rewrite (3rd pass) to
quizAPI.php?url=quizAPI.php&url=user/get/
(again)
- Rewriting process stops since the URL has passed through unchanged.
This still "works" (on Apache) since the url
parameter (as read by your PHP script) is still user/get/
(the 2nd instance of the url
param overwrites the first in the $_GET
array). And there is no rewrite-loop. LiteSpeed, however, might be triggering another pass by the rewrite engine (causing a "loop").
However, we need to prevent that second pass by the rewrite engine (on Apache as well) and I would expect this would resolve the issue on LiteSpeed as well.
One way is to prevent the rewrite from occurring when quizAPI.php
is requested. For example:
RewriteCond %{REQUEST_URI} !^/quizAPI\.php$
RewriteRule (.+) quizAPI.php?url=$1 [QSA,L]
However, this still rewrites all static assets (CSS, JS, images, etc.) to your script (which I'm assuming must "OK", since it "works" on Apache), but this might need further modification in the future.
Alternatively, if your URLs that you pass to quizAPI.php
don't contain dots (that otherwise delimit file-extensions) then it would be simpler to only match URLs that don't contain dots instead (which avoids the need for the preceding condition). For example:
RewriteRule ^([^.]+)$ quizAPI.php?url=$1 [QSA,L]
And this naturally avoids rewriting requests for your static assets as well.