You can use the -f
RewriteCondition to exclude files:
RewriteCond %{REQUEST_FILENAME} !-f #exclude files
RewriteRule ^(.*) index.php?__path=$1 [QSA] #catch everything
If you want to keep directories too you can do that with -d
.
Now if you call the URL:
website.net/path/to/file?query=string&foo=bar
You will get (in your $_GET
):
__path = "/path/to/file"
query = "string"
foo = "bar"
Don't use $_REQUEST
. It is non-standard and mixes $_GET
and $_POST
, it can lead to very strange bugs.