Reputation: 700
I'm trying to rewrite urls to allow only numbers and (optionally) the word "all" comma separated.
For example, something like this: mypage/23,15,all,2,all
I tried something, but there is a problem. First, this is my rule (probably syntatically wrong):
mypage/([\d,?(all)]+)
The problem here is that if a write mypage/23 works (correct), mypage/23,all works (correct), mypage/23,all,a works (because it detects 'a' of 'all', so wrong)
How can I modify the rule to accept only the entire word "all"?
Thank you.
Upvotes: 1
Views: 313
Reputation: 111
Try this: i think it should work
/([\d]+,(all)+)
[] for optional
() for grouping
Upvotes: 0
Reputation: 785146
You can use this regex:
RewriteRule ^mypage/((?:\d+|all)(,(?:\d+|all))*)/?$ target-url?str=$1 [L,NC,QSA]
There is no grouping of characters inside character class i.e. [...]
Upvotes: 3