Mobile app version of vmapp.org
Login or Join
Karen161

: What's the best way to redirect from domain to subdomain? 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

@Karen161

Posted in: #301Redirect #Redirects #Subdomain

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?

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

4 Comments

Sorted by latest first Latest Oldest Best

 

@Margaret670

With my .htaccess code, I check if the domain has the dub on the domain, then I redirect it to the subdomain without the 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 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]

10% popularity Vote Up Vote Down


 

@Gretchen104

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.

10% popularity Vote Up Vote Down


 

@Cofer257

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 ^(.*)$ subdir.mydomainsite.com/ [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: www.mattcutts.com/blog/switching-things-around/

10% popularity Vote Up Vote Down


 

@Steve110

It is ok to use a 30X header: 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.

bugsquash.blogspot.com/2008/12/google-chrome-caches-301-redirects.html superuser.com/questions/304589/how-can-i-make-chrome-stop-caching-redirects

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

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme