Everyone knows that wordpress have simple .htaccess code like below RewriteEngine on RewriteBase /

# only rewrite if the requested file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-s 

# pass the rest of the request into index.php to handle     
RewriteRule ^(.*)$ /index.php/$1 [L]

But when I redirect all demands to index.php, It becomes pretty cumbersome to deal with every rewrite in php. Presently I've got a logic in your mind, like conserve a db table with all of valid redirections. But nonetheless I'm not sure how to deal with rules likes ([-9]+).

If anybody has implemented something similar to this before or includes a logic in your mind, are you able to please guide me within this matter

The only purpose am carrying this out, happens because I would like versatility in adding/removing groups within the menu of my website. I'd rather not visit .htaccess each time and edit it whatsoever places. I wish to create a lot more like a Content management systems where user can also add remove groups

I do not comprehend the question, WordPress already handles all of this for you personally. Unless of course you mean you are not using WordPress? By which situation yes, it can be done in either case. What type of URL structure would you like? You can write a guide like so:

RewriteRule ^category/(.*)$  categories.php?cat=$1 [L]

To create a URL like domain.com/category/dogs rewrite to domain.com/groups.php?cat=dogs. Clearly you are able to adjust this the way you like, and write a couple of more similar rules for tags, posts etc.

Handling routing in php will be a more dynamic and 'elegant' solution. You could attempt utilizing a framework like CodeIgniter, this can manage routes for you personally instantly making simple to use to define custom routes. Most likely much better than writing a lot of .htaccess rules.

My suggestion is always to setup php based routing the fundamental idea is you make a move such as this:

RewriteEngine On

# skip all files with extensions other than .html
# this way if you want you can append the .html to dynamic pages
# which wont really exist as a file
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]

// redirect everything to your front controller
RewriteRule ^(.*)$ index.php [QSA,L]

Notice the way you simply make everythign visit index.php however, you dont rewrite the variables or anything. The reason being you'll exercise things to in line with the pattern from the URL with php. To be able to do that it's important to implement a router. Essentially a router requires a request and matches it against a pattern after which determines any parameters in line with the pattern.

You will find existing libraries available to get this done for you personally. For instance [cde].