The to destination looks good, but you’ll need to modify the regex a little bit. You’re currently capturing the first URI element, which is always going to be user, and the closing anchor stops it from matching any URI longer than one element.
There’s a number of very helpful sites for developing working regex; I like to use https://regexr.com/ because of the cheatsheet and detailed explanations. Plug /user/name/style.css into the the Text section and play with the Expression until the first capture group gets “name”.
You can use multiple rewrite destinations to “fall back” to index.php if the first rewrite doesn’t resolve to a file, e.g. to /folder/{1}/{2}?{query} /index.php.
But /user it is just a keyword in the url. I don’t have folder ‘user’, for ex.
my rewrite abowe must match url like /user/(\w+)/(.+) and rewrite to site_root/folder/{1} and if {2} is not empty then, url must me like site_root/folder/{1}/{2}
can you show me right way to do this?
ps in my case {1} will always be (\w+), not a ‘user’ as you said
That looks good, use that as your regex - like: r /user/(\w+)/(.+)
And your destination should be to /folder/{1}/{2}?{query} /index.php or similar. It will try that folder rewrite, and if it fails, it will use index.php instead.