Apache RewriteRule Flags
12 March 2022
Flag | Description |
---|---|
[NC] | Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. |
[QSA] | When the replacement URI contains a query string the default behavior of RewriteRule is to discard the existing query string and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined. |
[F] | Using the [F] flag causes the server to return a 403 Forbidden status code to the client. |
[G] | The [G] flag forces the server to return a 410 Gone status with the response. |
[L] | The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts this means that if the rule matches no further rules will be processed. |
Examples
[NC]
RewriteRule ^test$ /some.php [NC]
Rule above will accept both URIs /test and /TESt, case is ignored by NC flag.
[QSA]
RewriteRule ^test$ /some.php?q=2 [QSA]
Rule above will rewrite /test
to some.php?q=2
and it will also pass any additional query parameter.
For example:
/test?extra=1
will be rewritten as /some.php?q=2&extra=1