All you really need is one RewriteRule for that (with optional parts):
RewriteEngine on
RewriteRule ^([a-z]+)/(([a-z]+)/(([a-z]+)/(([a-z]+)/)?)?)?$ index.php?category=$1&product=$3&version=$5&config=$7 [L]
Please note that this code precludes you using extensionless filenames (no dot characters in the character range definitions) and this REQUIRES a category to have a product to have a version to have a config.
Please note that trailing /'s are reserved in the Apache world for directories AND that index.php will be forced to use internal absolute URIs for its support files (because of the different directory levels of your optional key/value pairs).
Your simplest and I think best option is to match path segments [^/]+ That is, match whatever happens to be between the slashes. If you put that in place of the [a-z]+ bits, you should be good to go.
The regex would consider that a category and rewrite. A couple ways around this are: 1) Clearly define the syntax of a category. For example, you could distinguish them by deciding that a category name must never contain a period and real files always must. Or 2) you could decide on a path prefix, such as **/products/**var1/var2/var3/var4. Or 3) you could condition the rewrite on whether the request already points to a real file. If it’s a real file, then assume it isn’t a category and don’t rewrite, or if it’s not a real file, then assume it’s a category and rewrite.
I think #2 is best, possibly with #3 in addition to handle special cases.