如何使用Htaccess重新排列URL路径

I need to rearrange a path

the path that works is this:

/profile/media/<username>

but to be more 'friendly' I have to use:

/<username>/profile/media

Is there a way in htaccess to test if this particular url has been passed and if so, rearrange it to the manner i need?

Many Thanks

jim

This is what worked for me using the answer below

RewriteRule ^(.+)/profile/media$ /?index.php?q=/profile/media/$1 [L,NC] 

Basically the site a Drupal site and Drupal just does NOT like dynamic first parts of a URL whereas this is exactly what I needed for the site to work and look a little better, the Client had asked me to set it so that the path was from the users POV rather that the POV of the site

Thanks to everyone who chipped in with helpful comments

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^(profile/media)/(.+)$ /$2/$1 [L,NC]