2013-04-08 147 views
-1

我试图让这个工作,但我有问题。当我去http://localhost/test/demo/并回显出价值p时,我得到demo。但是当我去http://localhost/test/demo/moretext/p的值是index.php/moretext为什么这样做呢? .htaccess文件位于test目录中。htaccess没有给出正确的值

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 

回答

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] 
+0

没了,只是加载 “WAMP的” defalut页。 – 2013-04-08 01:31:49

+0

修改我的答案。 – 2013-04-08 01:39:50

+0

仍加载“wamp的”默认页面。 – 2013-04-08 01:42:04

相关问题