To redirect a domain permanently with the .htaccess file follow the guide below.

Add the following code to your .htaccess file make sure to change yoururl.com first!

# User Added 301
RewriteCond %{HTTP_HOST} ^yoururl.com
RewriteRule ^(.*)$ http://www.yoururl.com/$1 [R=301,L]
# End of user added 301