htaccess规则:如何从url解析用户名

I got a user database with unique usernames and I want to set up virtual urls like: www.mypage.com/nickname

I've already tried RewriteRule ^ user.php?name=$1 [L] but this will also redirect ANY css and js which is not intended.

I was also thinking about parsing the 404 script or something but no idea how I would do that.

Any ideas?

You can make your rule conditional by adding ( RewriteCond ) conditions so that it doesnt rewrite existing files and dirs

RewriteEngine on

#don't rewrite existing dirs
RewriteCond %{REQUEST_FILENAME} !-d

#don't rewrite existing files
 RewriteCond %{REQUEST_FILENAME} !-f
#rewrite any uris to "/user.php" excluding files and dirs
RewriteRule ^([^/]+)/?$ user.php?name=$1 [NC,L]