Basically, I want to have this URL:
http://domain.tld/auth.php?state=somestate&token=somelongtoken
rewritten/redirected into this:
http://domain.tld/auth/validate/somestate/somelongtoken
I have been looking over the net for quite some time now, but I cannot figure out how to do this thing..
Also - would a redirect or a rewrite be the best here?
I am not going to use the URL for anything other than validating a user from a API, so it is just redirecting the user after visiting that page.
There is some untested code...
I would use a rewrite since you're saying that /auth.php will do a Location: already. There is really no point in sending two redirect. Plus that's bad practice with search engines (I know in this case it won't happen, just mentioning, because if it is bad for SEO, it's probably not that nice for your users.)
Note that the regex of the RewriteRule and previous conditions expects those two query string parameters to be in that very order. You'd need multiple lines to not force the order. But I would imagine that it isn't a problem.