We have a shared hosting account with Hostgator.

I've never had an issue like this with an add-on domain name with any web host: instead of showing as addondomainname.com it's showing as addondomainname.maindomainname.com in Google's results.

The domain name has been configured properly in cpanel and all our other add-on domain names are showing just the domain name in the SERPs.

Somebody suggested a write a .htaccess redirect.

My .htaccess knowledge is not that great, so excuse the basic question. I've looked on several sites, but not been able to find the right code.

I've tried adding the following to the add-on domain's directory, but it still shows addondomain.maindomain.com in my browser toolbar:

RewriteCond %{HTTP_HOST} ^addondomain.maindomain.com [NC]
RewriteRule (.*) http://www.addondomain.com [R=301,L]

What should the .htaccess code be please?

Thanks.