This requires apache's mod_rewrite module to be installed. What you want can be achieved through the following piece of code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^profiles/(.*)?$ profile.php?id=$1
</IfModule>
Example:
www.yourwebsite.com/profiles/1234 -> www.yourwebsitename.com/profile.php?id=1234
If you want more variables just modify the above line like below:
RewriteRule ^profiles/(.*)/(.*)?$ profile.php?id=$1&var2=$2
Just edit your .htaccess file and add the above lines, make sure you create a backup of your .htaccess before making any modifications.