开发者

RewriteRule to accept 3 parameters but 2nd & 3rd param are optional

mydomain.com/MyFolder/parameter-1

I have this htaccess RewriteRule -

RewriteRule ^([a-z0-9\-]+)/?$ index.php?c=$1 [N开发者_运维问答C,L]

The htaccess file is inside [MyFolder] and this only accept a single parameter.

How can do a RewriteRule to accept 3 parameters but the 2nd and 3rd parameters are optional so that the following 4 URLs are ALL possible

mydomain.com/MyFolder/param-1/param-2/param-3
mydomain.com/MyFolder/param-1
mydomain.com/MyFolder/param-1/param-2
mydomain.com/MyFolder/param-1/param-3

Edit : Ill make it that PARAM3 always starts with the word [pop]

Thanks


RewriteRule ^([a-z0-9\-]+)/?([a-z0-9\-]+)?/?([a-z0-9\-]+)?/?$ index.php?c=$1&d=$2&e=$3 [NC,L]

This would work for:

mydomain.com/MyFolder/param-1/param-2/param-3
mydomain.com/MyFolder/param-1
mydomain.com/MyFolder/param-1/param-2

with $_GET[d] and $_GET[e] having as value '' in certain cases.

Having:

mydomain.com/MyFolder/param-1/param-2
mydomain.com/MyFolder/param-1/param-3

Seems impossible to me as is, how can you know if the second is param 2 or param 3 ?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜