add_rewrite_rule with optional parameters

Found the solution, just had to remember all the ? marks.

It works when the regex is like this:

'index.php?catalogs=$matches[1]&p1=$matches[2]&p2=$matches[3]&p3=$matches[4]'

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)