Php htaccessurlrewrite
我有一个关于URL重写的问题。Php htaccessurlrewrite,php,.htaccess,url-rewriting,Php,.htaccess,Url Rewriting,我有一个关于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 但是类型不正确?这是我的.htaccess: RewriteEngine on RewriteCond %
当我现在调用这样的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
但是类型不正确?这是我的.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
我如何解决这个问题?
其他一切都很好。试着让你的火柴不贪婪:
RewriteRule ^error/(.*?)/(.*?)/(.*)/ error.php?type=$1&error=$2&file=$3
尝试使您的匹配不贪婪:
RewriteRule ^error/(.*?)/(.*?)/(.*)/ error.php?type=$1&error=$2&file=$3
确保使用
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]
确保使用
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]