Well, your rules are not considering the php file here (check that I've added the slash before all regexp in rules):
RewriteBase /www/
RewriteEngine On
RewriteRule ^/([a-zA-Z0-9_-]+)$ profile.php?u=$1
RewriteRule ^/([a-zA-Z0-9_-]+)/$ profile.php?u=$1
With this piece of code, http://localhost/profile_page.php?u=alice will never be matched. ^([a-zA-Z0-9_-]+)/$
only matches letters, numbers and underscore, so for example the question mark cannot be matched.
Try this (assumming that instead of profile.php you mean profile_page.php
RewriteBase /www/
RewriteEngine On
RewriteRule ^/profile_page.php/([a-zA-Z0-9_-]+)$ profile_page.php?u=$1
RewriteRule ^/profile_page.php/([a-zA-Z0-9_-]+)/$ profile_page.php?u=$1
Another improvement. You can set both expressions in only one.
RewriteBase /www/
RewriteEngine On
RewriteRule ^profile_page.php/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
I highly recommend you to remove the profile_page.php here in order to increase the url readability (I see and maybe you meant that format in your specification).
RewriteBase /www/
RewriteEngine On
RewriteRule ^/profile_page.php/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
RewriteRule ^/profile/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
RewriteRule ^/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
In that case you will be able to match these urls
* http://localhost.com/alice
* http://localhost:com/profile/alice
* http://localhost.com/profile_page.php/alice
To be able to match your own profile, just be sure you enable as well some routes for that, for example:
RewriteBase /www/
RewriteEngine On
RewriteRule ^/?$ profile_page.php
RewriteRule ^/me?$ profile_page.php
RewriteRule ^/profile_page.php/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
RewriteRule ^/profile/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
RewriteRule ^/([a-zA-Z0-9_-]+)/?$ profile_page.php?u=$1
Check that order matters here. The first that matches, the first that is applied. In that case I've used the same endpoint file. Check that $_GET['u'] isset in order to load the specified user or the one in session.
I'd highly recommend you to use some kind of front controller in order to be able to manage all routes given one single class (app.php for example), like Symfony or any modern PHP framework does.