Handling GET with htaccess [duplicate]

2019-09-17 12:12发布

问题:

This question already has an answer here:

  • RewriteRule that preserves GET parameters 3 answers

I have my .htaccess file redirecting all URLs to index.php?url=$1 as shown below:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [L]

But when the url is authenticate?code=blahblahblah the code= part is not pulled in, therefore meaning I cannot access it when handling the page D: Any help?

回答1:

You need the [QSA] flag then.



回答2:

use RewriteRule ^(.*)$ index.php?url=$1&%{QUERY_STRING} [L] instead