Whenever you are moving a site, it is best practice to use Htaccess 30 redirects. This is the standard practice for SEO purposes and it is also the method recommended by Google. I’ve been using this technique for a several years now and it works perfectly. For example if I wanted to move the contents of my current site to newsite.com, I could use the following syntax in my .htaccess file:
Redirect 301 / http://newsite.com/
However, recently, I had to move a subdomain and ran into problems with the 301 redirect.
Here’s the problem: I needed to redirect all URLs on a subdomain to completely different URL on a different subdomain. So:
Needed to 301 to:
I tried several up a simple 301 redirects in .htaccess but they all didn’t work. Some of my tests were:
Redirect 301 http://example.oldsite.com/this-is-my-page http://example.newsite.com/this-is-really-my-page
Redirect 301 example/this-is-my-page http://example.newsite.com/this-is-really-my-page
None of these techniques worked until I used the solution below.
redirecting subdomains using Htaccess 301 redirects
It turns out that 301 redirects recognize subdomains as separate websites. So all I had to do was create a new htaccess file inside the main folder of the subdomain and point it to the new site. So, if I had a subdomin on my old site called subdomain and it was located at oldsite.com/subdomain, I simply had to create a new htaccess file inside oldsite.com/subdomain and have it point to the new site and it works like magic.