Apache htaccess未提供正确的值

Apache htaccess未提供正确的值,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正试图让这项工作,但我有问题。当我转到http://localhost/test/demo/并回显pI getdemo的值。但是当我进入http://localhost/test/demo/moretext/p的值是index.php/moretext为什么这样做?.htaccess文件位于test目录中 Options +FollowSymLinks RewriteEngine On RewriteBase /test/ RewriteCond %{REQUEST_FILENAME} !-

我正试图让这项工作,但我有问题。当我转到
http://localhost/test/demo/
并回显
p
I get
demo
的值。但是当我进入
http://localhost/test/demo/moretext/
p的值是
index.php/moretext
为什么这样做?
.htaccess
文件位于
test
目录中

Options +FollowSymLinks
RewriteEngine On
RewriteBase /test/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/(.+?)/$ index.php?p=$1&file=$2
RewriteRule ^(.+?)/$ index.php?p=$1

您可以在
/test
目录下的一个.htaccess文件中尝试此操作:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI}  !index\.php       [NC]
RewriteCond %{REQUEST_URI}  ^/test/([^/]+)/([^/]+)/?$ [NC]
RewriteRule .*  /test/index.php?p=%1&file=%2  [L]

RewriteCond %{REQUEST_URI}  !index\.php       [NC]
RewriteCond %{REQUEST_URI}  ^/test/([^/]+)/?$ [NC]
RewriteRule .*    /test/index.php?p=%1  [L]

不,这只是加载“wamp的”defalut页面。仍然加载“wamp的”默认页面。将
/index.php?p=%1
更改为
/test/index.php?p=%1
,并将
/index.php?p=%1&file=%2
更改为
/test/index.php?p=%1&file=%2
有效!你是对的。我没有使用重写库。我将修改我的答案。谢谢!你帮了大忙!