2013-04-08 82 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