This is performed by an apache module called mod_rewrite. It simply changes the provided url into one that provides the processing script the necessary querystring to process the request.
With what you have above, you will have a difficult time controlling it. If you were to match anything tha tis ^/X, then it will always assume it matches a username. A better target may be to use /user/X, so you can identify that as being a username in particular.
See this link for more information on mod_rewrite: http://httpd.apache.org/docs/current...d_rewrite.html