0

下面的代码效果很好,但是如果我有一个 URL,例如 /calgary/dashboard.php?step=change-password PHP 将无法识别 $_GET['step']

我可以在这里更改什么以便我可以使用 $_GET['']

RewriteEngine On
RewriteBase /city_name

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ /city_name/index.php?page=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /([^\./]+)\.php$
RewriteCond %{DOCUMENT_ROOT}/city_name/%1.php -f
RewriteRule ^(.*)/([^\./]+)\.php$ /city_name/$2.php?page=$1 [L]
4

2 回答 2

1

使用 QSA,

RewriteRule (.*)/$ /city_name/index.php?page=$1 [L,QSA]

RewriteRule ^(.*)/([^\./]+)\.php$ /city_name/$2.php?page=$1 [L,QSA]
于 2012-07-20T23:27:33.207 回答
1

将查询字符串标志 (QSA) 添加到规则应该可以修复它,例如:

RewriteRule ^(.*)/([^\./]+)\.php$ /city_name/$2.php?page=$1 [QSA,L]
于 2012-07-20T23:28:03.253 回答