Apache 为什么这条规则不起作用?(xampp)
我在我的项目根文件夹Apache 为什么这条规则不起作用?(xampp),apache,.htaccess,mod-rewrite,url-rewriting,xampp,Apache,.htaccess,Mod Rewrite,Url Rewriting,Xampp,我在我的项目根文件夹c:\xampp\htdocs\myproject\ RewriteEngine on RewriteRule ^(.+)$ test.php?stuff=$1 [QSA,L] 还有一个test.php(没有index.php) 一切正常。我做错了什么?之所以会得到目录列表,是因为当.htaccess放在/myproject/中时,您的URLlocalhost/myproject实际上发送了一个空的每目录URI 您的URI模式是(.+),它显然与空字符串不匹配,因此不
c:\xampp\htdocs\myproject\
RewriteEngine on
RewriteRule ^(.+)$ test.php?stuff=$1 [QSA,L]
还有一个test.php
(没有index.php)
一切正常。我做错了什么?之所以会得到目录列表,是因为当
.htaccess
放在/myproject/
中时,您的URLlocalhost/myproject
实际上发送了一个空的每目录URI
您的URI模式是(.+)
,它显然与空字符串不匹配,因此不会触发规则,并且由于您没有index.php
或index.html
,所以您会得到目录列表
正确的规则应该是:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ test.php?stuff=$1 [QSA,L]
PS:请注意,删除RewriteCond
将为localhost/myproject
调用test.php
,但它将作为test.php?stuff=test.php&stuff=
在内部调用
RewriteRule ^(.+)$ http://www.google.de [L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ test.php?stuff=$1 [QSA,L]