Php 捕获htaccess中的多个参数
我有一个URL act/city/1/page.html,其中city,1来自数据库。 我使用的htaccess规则是:Php 捕获htaccess中的多个参数,php,.htaccess,Php,.htaccess,我有一个URL act/city/1/page.html,其中city,1来自数据库。 我使用的htaccess规则是: RewriteRule ^act/city/([^/]+)\.html$ page\.php?i=$1&p=$2&%{QUERY_STRING} [L] 如果我用php打印请求,它会显示:Array[id]=>city/1,而不是 数组[id]=>1 请帮助我,它对我有用。此外,您向我们展示的规则与您的URL不符 我的规则: RewriteRule ^act
RewriteRule ^act/city/([^/]+)\.html$ page\.php?i=$1&p=$2&%{QUERY_STRING} [L]
如果我用php打印请求,它会显示:Array[id]=>city/1,而不是
数组[id]=>1
请帮助我,它对我有用。此外,您向我们展示的规则与您的URL不符 我的规则:
RewriteRule ^act/city/([^/]+)/([0-9]+)\.html$ /page.php?i=$1&p=$2&%{QUERY_STRING} [L]
请注意,我在page.php之前添加了一个斜杠
我的网址:
http://localhost/act/city/1/2.html
我的结果是:
array(2) {
["i"]=>
string(1) "1"
["p"]=>
string(1) "2"
}
你可以试试下面的代码
RewriteRule ^act/city/([^/]+)\.html$ page.php?i=$1&p=$2&%{QUERY_STRING} [L]
没有必要在“$”后面加斜杠
谢谢。让我们看看你的其他规则!请求转储错误,重定向中没有id参数!