2012-08-31 62 views
2

我有一個關於URL重寫的問題。
當我現在請這樣的URL:Htaccess URLRewrite

http://domein.ext/error/mysql/2/class.core.php/

它將輸出這個在德GET變量:

$_GET['type'] = mysql/2/class.core.php/.php/mysql 
$_GET['error'] = 2 
$_GET['file'] = class.core.php 

但類型不正確?這是我的.htaccess:

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 

RewriteRule ^(.*)$ $1.php 

RewriteRule ^index/password/ index.php?error=password 
RewriteRule ^error/(.*)/(.*)/(.*)/ error.php?type=$1&error=$2&file=$3 

我該如何解決這個問題? 和其他一切工作正常..

+2

請注意'.'匹配'/'。 –

回答

0

確保你結束所有規則與L標誌。將您的代碼更改爲:

RewriteEngine on 

RewriteRule ^index/password/?$ index.php?error=password [L,QSA,NC] 

RewriteRule ^error/([^/]+)/([^/]+)/([^/]+)/?$ error.php?type=$1&error=$2&file=$3 [L,QSA,NC] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*)$ $1.php [L] 
0

請嘗試將比賽非貪婪:

RewriteRule ^error/(.*?)/(.*?)/(.*)/ error.php?type=$1&error=$2&file=$3