Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess redirect to show add-on domain as domain name in serps

How to write .htaccess redirect

     

1Lit

6:32 pm on Apr 25, 2012 (gmt 0)

10+ Year Member



We have a shared hosting account. 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.

g1smd

7:28 pm on Apr 25, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Use example.com in this forum.

You'll need more than htaccess here.

You need to alter the DNS entries too.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.maindomain\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


or

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


will usually work.

This code goes in the place that example.maindomain.com/.htaccess would point to.

What happens when you type example.com or www.example.com in your browser address bar?

1Lit

9:38 pm on Apr 25, 2012 (gmt 0)

10+ Year Member



Thank you for that.

The first code you provided works a treat.

When I type in addonexample.example.com in the address bar, it not redirects to www.example.com

I've resubmitted it to Google, so hopefully it'll update in the SERPs too.

g1smd

9:53 pm on Apr 25, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



it not redirects

or

it now redirects

?