Very quickly, you must enable mod_rewrite on your test server. Then, if NOT localhost, try to match everything (except the dot character) with or without a trailing slash and redirect to profile?
Please have a thorough read of the mod_rewrite tutorial at http://dk.co.nz/seo for setup directions and learning how to write effective mod_rewrite code (with many real world examples).
For the benefit of someone else with the same problem, in addition to enabling mod_rewrite (the command sudo a2enmod rewrite should work, on Linux), you also have to open up the file where you’ve defined your VirtualHost (by default, it’s /etc/apache2/sites-available/default) and then make sure your value for ‘AllowOverride’ is ‘All’.
Basically, you should have a line that reads: AllowOverride All
Once you make the edit, make sure you reload/restart Apache.
What this does is, it tells Apache that it’s ok to allow users to use any directive in their .htaccess file to override the default Apache settings.
If the ‘AllowOverride’ is set to ‘None’, then your rules in .htaccess won’t work.