开发者

catch multiple parameters in htaccess

I have an URL act/city/1/page.html where city,1 are coming from database. The htaccess rule I use is:

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

If I print my REQUEST in php, it displays: Array ( [id] => city/1 ) instead of Array ( [id] => 1 ).

Kindly assist


It works for me. Also, the rule you have shown us is not the correct one for your URL.

My rule:

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

Note that I added a slash before page.php.

My URL:

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

My result:

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


you can try below code

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

There is no need to put Slash() after '$'.

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜