2

我有一个关于 URL 重写的问题。
当我现在调用这样的 URL 时:

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

它将在 de GET 变量中输出:

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

但是 TYPE 不正确?这是我的 .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

我该如何解决这个问题?其他一切都很好..

4

2 回答 2

0

尝试使您的匹配不贪婪:

RewriteRule ^error/(.*?)/(.*?)/(.*)/ error.php?type=$1&error=$2&file=$3
于 2012-08-31T15:15:39.167 回答
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]
于 2012-08-31T15:17:15.897 回答