I'm really struggling with this regex.
We're launching a new version of our "groups" feature, but need to support all the old groups at the same URL. Luckily, these two features have different url patterns, so this should be easy? Right?
- Old: domain.com/group/$groupname
- New: domain.com/group/$groupid/$groupname
The current regex I was using in the regex to redirect old groups to the old script was: RewriteRule ^(group/([^0-9/].*))$ /old_group.php/$1 [L,QSA]
It was working great until a group popped up called something like: domain.com/group/2009-neato-group
At which point the regex matched and forced the new group to the old code because it contained numbers. Ooops.
So, any thoughts on a regex that would match the old pattern so I can redirect it?
Patterns it must match:
Patterns it cannot match:
The best way I've thought about it is that it cannot start with "group-slash-numbers-slash", but haven't been able to turn that into a regex. So, something to negate that pattern would probably work.
Think the other way around: If the url matches ^group/[0-9]+/.+, then it is a new group, so redirect these first (with a [L] rule). Everything else must be a old group, you can keep your old rules there.