Hi :) There's no better way to explain this one than by example.
USUAL CASE
I use this rewrite rule:
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L]
To do something like:
# abc.com/home => abc.com/index.php?params=home
开发者_运维技巧
However, this discards any preexisting GET parameters, so with:
http://localhost/ajax/workouts/getExerciseDetails?exerciseID=41
I get:
params=ajax/workouts/getExerciseDetails
When I need:
params=ajax/workouts/getExerciseDetails&exerciseID=41
SO... My question in English is: Is there a way to conditionally append any preexisting GET params (aka the string after the '?') to the replacement AND still satisfy my main use of this regex?
If this cannot be done in the same rewrite rule, perhaps by using an if/then/else?
Thanks!
Just set the QSA flag to get the original query automatically appended to the new:
RewriteRule ^(.+)$ index.php?params=$1 [L,QSA]
精彩评论