开发者

n parameters in htaccess mod-rewrite rule

开发者 https://www.devze.com 2023-04-12 03:10 出处:网络
I need a rewrite rule that can handle any number of arguments, for example: localhost/1/2/3/4/5/6/... Is it possible to write开发者_StackOverflow社区 a rewrite rule for this? There´s no problem to

I need a rewrite rule that can handle any number of arguments, for example:

localhost/1/2/3/4/5/6/...

Is it possible to write开发者_StackOverflow社区 a rewrite rule for this? There´s no problem to collect them all in one parameter with braces to get PHP to handle them as a array if that would help.

Kind Regards


The easiest approach is going to look something like this:

RewriteRule ^([^/]*(/[^/]*)*)$ localhost?index.php?var=$1

You'll end up dealing with x/y/z in 'var', but without knowing the number of arguments ahead of time that's the best you can do.

(For clarification, [^/] means "any character except '/'".)

0

精彩评论

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

关注公众号