htaccess RewriteRule返回空$ _GET

时间:2015-02-12 10:49:19

标签: php .htaccess mod-rewrite get

我的重写规则:

RewriteEngine On
RewriteRule ^popup/(.+)/$ /popup.php?name=$1 [L,QSA]

在本地它工作正常,在$ _GET中我得到具有预期值的变量“name”。但它不适用于生产服务器。我的$ _GET是空的,但是服务器在popup.php脚本上重定向我。

EDIT1: popup.php上的$ _SERVER值为var_dump:

SERVER_SOFTWARE => Apache/2.2.15 (CentOS)
SERVER_ADDR => 127.0.0.1
SERVER_PORT => 80
REMOTE_ADDR => 127.0.0.1
DOCUMENT_ROOT => /var/www/site.dom/htdocs
SERVER_ADMIN => root@localhost
SCRIPT_FILENAME => /var/www/site.dom/htdocs/popup.php
REMOTE_PORT => 60763
GATEWAY_INTERFACE => CGI/1.1
SERVER_PROTOCOL => HTTP/1.0
REQUEST_METHOD => GET
QUERY_STRING => 
REQUEST_URI => /popup/work/
SCRIPT_NAME => /popup.php
PATH_INFO => /work/
PATH_TRANSLATED => redirect:/parse_request.php/
PHP_SELF => /popup.php/work/

什么PATH_TRANSLATED意味着什么?

1 个答案:

答案 0 :(得分:2)

这是由于您的网络服务器上的选项MultiViews。在.htaccess上添加此行以禁用它:

Options -MultiViews

MultiViews之前运行的Apache's content negotiation module使用选项mod_rewrite,并使Apache服务器匹配文件扩展名。因此/file可以在网址中,但它会提供/file.php,从而取代您的重写规则。