htaccess的重写查询字符串在Apache 2.2的消失,但在工作2.4 [英] htaccess rewrite QueryString disappears in Apache 2.2 but works in 2.4

查看:139
本文介绍了htaccess的重写查询字符串在Apache 2.2的消失,但在工作2.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是该规则:

RewriteRule ^api/([\w-]+)/?$ api.php?method=$1 [QSA]

在本地的Apache服务器2.4,它可以让我重写这样的:

On local Apache 2.4 server, it allows me to rewrite like:

/api/create-account/?name=abcd 

/api.php?method=create-account&name=abcd

在生产服务器上,这是Apache 2.2的,请求进入 api.php 。但我觉得不是我的脚本查询字符串参数。如果我倾倒 $ _ REQUEST $ _ GET $ _ POST ,我只得到空数组。

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.

我是什么失踪?

推荐答案

您需要关闭在Multiviews:

You need to turn off Multiviews:

Options -Multiviews

在Multiviews是告诉它尝试匹配到物理文件的请求mod_negotiation模块选项。当它看到像 / API / somtehin 一个请求,然后看到,有一个文件名为 api.php ,它会映射到该文件向右走,完全绕过了mod_rewrite的。

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.

这篇关于htaccess的重写查询字符串在Apache 2.2的消失,但在工作2.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆