I have trouble with rewrite rule
my link is www.something/group/group_id/place/groupName with this rewriteBase /
RewriteRule ^group/(.*)/(.*)/(.*)$ /group.php?gid=$1 [QSA,NC,L]
somet occasions my url will come www.something/group/group_id/groupName.
In the two cases I must rewrite to group.php and that i only need groupid. Crafting rewrite rule to operate both in situation?
Try that one:
It matches for
I not used at all the RewriteRule, therefore it is not examined. And perhaps should you add the "Regex" Tag for your question you will get more solutions -)
Either use lazy quantifiers or prevent each matching group from matching the
/ itself. How you get it presently, the very first group will match around it may leading to undesirable results.
RewriteRule ^group/(.*?)/(.*?)/(.*?)$ /group.php?gid=$1 [QSA,NC,L] RewriteRule ^group/([^\/]*)/([^\/]*)/([^\/]*)$ /group.php?gid=$1 [QSA,NC,L]
A much better way, to permit individuals to omit unnecessary parts (read: unnecessary to judge the end result around the server side), you can even make a move such as this:
RewriteRule ^group/(\d+)(/.*)?$ /group.php?gid=$1 [QSA,NC,L]
(This is dependant on the assumption that the group id is really a number)