I acquired an element-based system that I am attempting to perform some routing for implementing mod_rewrite. For whatever reason, I can not obtain the syntax 100% suitable for every case to operate correctly. Listed here are the 4 test cases (I'm able to only obtain the 4g iphone to operate):

/component/action/24_char_id  should be rewritten as /index.php?c=component&a=action&id=24_char_id
/component/24_char_id  should be rewritten as /index.php?c=component&id=24_char_id
/component/action should be rewritten as /index.php?c=component&a=action
/component should be rewritten as /index.php?c=component

Fundamental essentials three rules I've to date:

RewriteRule ^([^/]+)/(.*)/([0-9a-z]{24})?/?$ /index.php?c=$1&a=$2&id=$3 [L,QSA]
RewriteRule ^([^/]+)([0-9a-z]{24})?/?$       /index.php?c=$1&id=$2      [L,QSA]
RewriteRule ^([^/]+)(?:/(.*))?/?$            /index.php?c=$1&a=$2       [L,QSA]

The Web addresses ought to be rewritten as specified above e.g. /index.php?c=$1&a=$2&id=$3, where "c" may be the component, "a" may be the action and "id" may be the 24 character lengthy id. Observe that you will find three variants from the URL within this plan.

Any help could be appreciated -- I am stuck!

First got it determined after a little trial &lifier error:

RewriteRule ^([^/]+)/?([0-9a-z]{24})?/?$ /index.php?c=$1&id=$2 [L,QSA]
RewriteRule ^([^/]+)/([a-z]+)/?([0-9a-z]{24})?/?$ /index.php?c=$1&a=$2&id=$3 [L,QSA]