Try this rule:
RewriteRule ^profile/([^/]+)$ profile.php?user_name=$1
This will rewrite requests of /profile/
foobar
to /profile.php?user_name=
foobar
. Note that you just can rewrite the user name. You script will then have to look up the user ID if necessary.