【发布时间】:2018-03-26 08:17:14
【问题描述】:
我有以下 .htaccess 文件
RewriteEngine on
RewriteRule ^(.*)/?$ index.php?file=$1 [L]
所以我希望它将 mysite.com/foobar 转发到 mysite.com/index.php?file=foobar
我有以下 index.php 文件
<?php
var_dump($_GET);
?>
无论我调用哪个url(mysite.com、mysite.com/foobar、mysite.com/test),index.php的输出总是
array(1) { ["file"]=> string(9) "index.php" }
而我期待一个
array(1) { ["file"]=> string(0) "" }
array(1) { ["file"]=> string(6) "foobar" }
array(1) { ["file"]=> string(4) "test" }
$_SERVER['QUERY_STRING'] 也返回“file=index.php”
我认为不涉及任何其他 htaccess 文件,当我将随机字符写入 .htaccess 文件时,我会收到内部服务器错误(如预期的那样),如果我更改参数“文件”的名称或更改将文件“index.php”的名称改为“test.php”问题保持不变(显示 test.php 而不是 index.php)
【问题讨论】:
标签: php .htaccess redirect mod-rewrite