SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    311
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem: Search engines indexing addon domain as a subdomain

    Hi,

    I started a new website using an addon domain and it is indexed by Google in three formats:

    1. domain.com
    2. domain.maindomain.com
    3. maindomain.com/domain

    This never happened to me before. I found the following code on the web to make .htaccess redirects:

    .htaccess in the domain.com folder:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^www.domain.maindomain\.com
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
    
    RewriteCond %{HTTP_HOST} ^domain.maindomain\.com
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
    .htaccess in the maindomain.com folder:

    Code:
    RewriteEngine On
    Redirect /domain http://www.domain.com
    The effect is not yet seen since I inserted the code a few minutes ago.

    Is this the best solution? Have you ever had a similar issue?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    ademmeda,

    What you're describing is caused by the way that your host has setup your account. Mine are similarly setup but I don't try to access the addon domains other than by (www.)addondomain.com.

    Your .htaccess looks fine (albeit I'd recommend regex of .? and redirection which replaces /$1 with %{REQUEST_URI}) so I wouldn't worry about that.

    As for SEs, they take WEEKS to update. However, that said, if you can still access your domain by addon.main.com, then it's possible that they will not remove that (despite your 301 redirections).

    My advice is not to sweat the petty stuff - you've done what you can to resolve that situation.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    311
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    ademmeda,

    What you're describing is caused by the way that your host has setup your account. Mine are similarly setup but I don't try to access the addon domains other than by (www.)addondomain.com.

    Your .htaccess looks fine (albeit I'd recommend regex of .? and redirection which replaces /$1 with %{REQUEST_URI}) so I wouldn't worry about that.

    As for SEs, they take WEEKS to update. However, that said, if you can still access your domain by addon.main.com, then it's possible that they will not remove that (despite your 301 redirections).

    My advice is not to sweat the petty stuff - you've done what you can to resolve that situation.

    Regards,

    DK
    Thanks for your comment David. I am afraid I didn't understand this part: "albeit I'd recommend regex of .? and redirection which replaces /$1 with %{REQUEST_URI}"

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by ademmeda View Post
    Thanks for your comment David. I am afraid I didn't understand this part: "albeit I'd recommend regex of .? and redirection which replaces /$1 with %{REQUEST_URI}"
    ademmeda,

    The use of (.*) can cause problems (generally, looping code) but the difference between Apache 1.x and Apache 2.x can also cause problems. The best reason to merely match anything then redirect to the %{REQUEST_URI} is that it already exists!

    Better yet, your other code can be combined (or deleted) as you don't need the redirection to domain.com in the maindomain's .htaccess if you're using
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule .? http://www.domain.com%{REQUEST_URI} [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^www.domain.maindomain\.com
    RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=permanent,L]
    
    RewriteCond %{HTTP_HOST} ^domain.maindomain\.com
    RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=permanent,L]
    OR merely
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !www\.domain\.com$
    RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=301,L]
    Since what you want is www.domain.com, this will redirect only if not www.domain.com and it will then leave the {REQUEST_URI} (as seen in the domain's directory) alone.

    Regards

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •