-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
To reproduce
-
$webroot/-
index.php<?php header('Content-Type: application/json'); echo json_encode($_GET); -
.htaccessRewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L]
-
Test:
- ✅
https://example.com/?a=1→{"a":"1"} - ❓
https://example.com/cccc?a=1→{}
Expected behavior
The behavior above makes sense logically, since the URI is rewritten to index.php, with no query string, so the url params should not be preserved. But it seems that Apache will preserve the url params in this case. In fact, many applications (including Wordpress) use something like RewriteRule ^ index.php [L] and assume that the url params will be preserved.
(Workaround: RewriteRule ^ index.php?%{QUERY_STRING} [L]. #36 was discovered exactly due to this workaround)
I do not know the exact mechanism of Apache very clearly.
- Will
RewriteRule ^.*? index.php [L]also preserve the url params? - If the destination already contains a query string (
RewriteRule ^ index.php?a=4&b=3 [L]), will the original url params be still preserved? If so, how will they be merged with the new ones specified in the query string?
If you intend to change the behavior, please research carefully.
Metadata
Metadata
Assignees
Labels
No labels