Using the [L] flag when redirecting to another host
apache docs mention
You almost always want to use
[R]
in conjunction with[L]
(ie use[R,L]
) because the flag itself is[R]
http://thishost[:thisport]
in the URI, but then passes that value to the next rule in the ruleset, which can often lead to "Invalid URI in request".
Now let's say I have a rewrite statement like this:
RewriteRule ^pass/?$ https://www.example.com/ [R,NC]
Since I'm redirecting my client to a different host / domain here, is it really necessary to pass the flag [L]
?
Were there any effects if I also use the flag [QSA]
?
source to share
Good question.
In all of my testing, I was unable to create a scenario where an exception to L
this rule shows a change in overall behavior. Only the change happens internally, as setting L
flag force mod_rewrite
starts the loop rewrite
immediately and not until the end of the file. So IMO s is L
better for performance reasons, if not for other reasons.
A QSA
: It is absolutely unnecessary here, as it QSA
is only required when your rule changes QUERY_STRING
what is wrong here.
source to share