change ~username from url

Apache allow Per-user web directories. To change the url http://localhost/~username/sitename to http://localhost/sitename, disable the apache userdir module.

To remove ~username from url and access your site in web root as //http://localhost/sitename execute the following line in Terminal
sudo a2dismod userdir

Restart apache server to activate new configuration.

sudo /etc/init.d/apache2 restart

Conform is web root directory configured correctly.
"a2dismod" disable apache module. If you want to enable apache module use "a2enmod".