homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

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

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

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?




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

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]


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?


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

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.


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

it not redirects


it now redirects


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved