htaccess rewrite QueryString disappears in Apache 2.2 but works in 2.4

柔情痞子 提交于 2020-01-16 00:29:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!