Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to install my new site content on a subdomain like subdir.mydomainsite.com instead of the root domain.

This is a new domain and not previous content to redirect. The root URL will be empty and inaccessible to anyone trying to browse the root site mydomainsite.com and will be redirected to subdir.mydomainsite.com automatically.

What's the best way to do this? I thought about a simple index.php with an 301 redirect from root to subdomain, but not I'm not sure if there's a better SEO way to do it. Will Google find this redirection weird and penalize the site in some way?

share|improve this question
    
Does Your Host support creating subdomains for your domain? If so, install the subdomain using your domain control panel. During Creation, it should ask you for a path. My host defaults to \subdomains\name_of_your_subdomain. After this, you install your content into that folder. Doing it this way ensures your hosts DNS seervers update, so you won't need a 301 etc. After you've moved your content, remove the folder that had the content in it from the root directory, and update the site links accordingly –  E Carter Young May 1 at 21:35

4 Answers 4

Setup both the domain and the subdomain in google webmastertools, and set your preferred version to be the subdomain one, then in the 'naked' domain (mydomainsite.com) if you are using apache, put this in the .htaccess (mydomainsite.com/.htaccess)

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

and all the requests for any url on mydomainsite.com will be 301'ed to the subdir.mydomainsite.com (but google will only show the subdir one in its SERPS)

[ I have implemented this strategy for moving sites across domains many times, and never have issues ]

Here is how Matt Cutts moved his domains: http://www.mattcutts.com/blog/switching-things-around/

share|improve this answer
1  
+1, minor point, it's something you see a lot, but you don't need to escape the periods (.) in the RewriteRule substitution, since it's not a regex. –  w3d May 2 at 13:40
    
Thanks :) Ill remember that, I just do it as habit now –  Jonathan May 2 at 17:11
    
Thank you all for your answers, I guess this is the best method to cover any possible backlink to root domain. I can't vote because I'm new here, sorry. –  Mbbc May 2 at 19:40
    
you can mark the question as answered though: webmasters.stackexchange.com/help/someone-answers –  Jonathan May 2 at 19:44

It is ok to use a 30X header: https://support.google.com/webmasters/answer/83105?hl=en.

But it will be cached by browser. So when you decide to use example.com some users will not see it.

So I would recommend set redirect from example.com/some-page.html to sub.example.com.

Do redirect with PHP: http://www.php.net/manual/en/function.header.php.

share|improve this answer

With my .htaccess code, I check if the domain has the www. dub on the domain, then I redirect it to the subdomain without the www. dub on it. Also, because I don't think you want to change it, I place a 301 Redirect on it also.

I forgot to mention, usually people do not use the www. on the subdomain also, so I am guessing that you don't want people to use it either.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^/?$ "http\:\/\/sundomain\.domain\.com\/" [R=301,L]
share|improve this answer

Technically it is possible with Apache or PHP also with JavaScript too.

But I can not recommend it, because from SEO viewpoint root domain is more important than subdomains. Redirecting from root to subdomain have two problem. Firstly users with direct visiting must type long address on browser. Secondly search engines detect contents as second level of importance.

You can use any subdomain for your contents but I am recommending linking from main page to subdomains.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.