Posted on


RewriteRule Flags

Documentation about Rewrite Rule Flags

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.


Typically the following construct is used to forward all requests to non-existing files to your front controller:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

This configuration checks if the requested filename either exists or is a directory. If this is not the case, it will call the file index.php. The [L] means this is the last match that needs to be made and following rewrite-rules will be skipped.

Starting with Apache 2.2.16 this can be done with the fallback resource:

FallbackResource /index.php