WordPress URL not working?

This is not how rewrite_rules works in WordPress.
You miss two things.

  1. Match. It has $1, but in reality (take a look to example), you need to work with $matches.
  2. Your Query Var. You using q, but its not wp native or declared in example code. You can use one of the public ones or declare your query var and logic behind it.
  3. If you are OK with Regular Expressions and already implemnt first two changes, but it still doesn’t work – I would suggest to use debug bar and my plugin debug bar rewrite rules