2011-06-14 68 views
0

我有一个URL act/city/1/page.html其中城市,1来自数据库。 我使用的htaccess的规则是:捕获htaccess中的多个参数

RewriteRule ^act/city/([^/]+)\.html$ page\.php?i=$1&p=$2&%{QUERY_STRING} [L] 

如果我打印我的要求在PHP中,它显示:Array ([id] => city/1)代替 Array ([id] => 1)

Kindly assist

+0

向我们展示您的其他规则! REQUEST转储是错误的,您的重定向中没有'id'参数! – powtac 2011-06-14 11:08:38

回答

0

它适合我。另外,您向我们显示的规则对于您的网址并不正确。

我的规则:

RewriteRule ^act/city/([^/]+)/([0-9]+)\.html$ /page.php?i=$1&p=$2&%{QUERY_STRING} [L] 

注意,我page.php之前加斜杠。

我的URL:

http://localhost/act/city/1/2.html 

我的结果:

array(2) { 
    ["i"]=> 
    string(1) "1" 
    ["p"]=> 
    string(1) "2" 
} 
0

你可以试试下面的代码

RewriteRule ^act/city/([^/]+)\.html$ page.php?i=$1&p=$2&%{QUERY_STRING} [L] 

没有必要 '$' 后放斜杠()。

谢谢。