0

在 Windows 服务器上,我们运行 Helicon Ape 来运行.htaccess规则并安装 PHP。我.htaccess在根目录的文件中有以下行:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^test/(.*)$ test/handle.php?path=$1 [L]
</IfModule>

我在文件中编写了以下代码handle.php

echo $_GET["path"];
exit;

当我输入这样的任何网址时:http://mysite.com/test/test.zip或者http://mysite/test/FILENAME.EXT打印FILENAME.EXT它只是打印handle.php为输出!怎么了?

4

1 回答 1

1

尝试添加条件以防止重写handle.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  !^/test/handle.php$
RewriteRule ^test/(.*)$ test/handle.php?path=$1 [L]
</IfModule>
于 2013-06-26T09:44:06.617 回答