问题
Following is the rule:
RewriteRule ^api/([\w-]+)/?$ api.php?method=$1 [QSA]
On local Apache 2.4 server, it allows me to rewrite like:
/api/create-account/?name=abcd
to
/api.php?method=create-account&name=abcd
On production server, which is Apache 2.2, the request goes to api.php
. But I find not query string parameter in my script. If I dump $_REQUEST
, $_GET
or $_POST
, I only get empty array.
What am I missing?
回答1:
You need to turn off Multiviews:
Options -Multiviews
Multiviews is a mod_negotiation option that tells it to try to match a request to physical files. When it sees a request like /api/somtehin
and then sees that there's a file named api.php
, it will map to that file right away, completely bypassing mod_rewrite.
来源:https://stackoverflow.com/questions/21361616/htaccess-rewrite-querystring-disappears-in-apache-2-2-but-works-in-2-4