Reputation:
.htaccess is a bit new to me!
I have a current site located at www.domain.com and I'm building a new site at new.domain.com.
When the new site is finished, I want to re-direct all traffic to the new subdomain.
Also, I want to resolve url canonicalization at the same time.
Any help appreciated! Thanks Mark
Upvotes: 7
Views: 36825
Reputation: 13
I would suggest you use this code so you don't have to worry about the "www" part of the URL address.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite\.com$ [NC]
RewriteRule ^(.*)$ http://subdomain.mysite.com/ [L,R=302]
Upvotes: 1
Reputation: 11
RewriteEngine On
RewriteRule (.*) http://new.domain.com/$1 [R=301,L]
this just did the trick in my case. Perfect! Now all the links shown by Google redirect from the top domain to the same link at the subdomain.
Upvotes: 1
Reputation: 176552
There are several different solutions. The best one, both from SEO and User perspective, is the one-to-one 301 redirect. It preserves your link juice and at the same time redirects the client to the exact location on the new website.
If you have mod_alias enabled, I would suggest a simple
RedirectMatch 301 ^(.*)$ / http://new.domain.com/$1
The result instruction can be accomplished with
RewriteEngine On
RewriteRule (.*) http://new.domain.com/$1 [R=301,L]
The second one is the best choice if you need to chain multiple conditions and filters. For example, if you need to redirect only certain hosts or clients depending on User Agent header.
Remember: mod_redirect takes precedence over mod_alias.
Upvotes: 8
Reputation: 63179
Why do not point the old domain to the new site, once it is finished? I think it should be no problem to point to domains on the same directory.
Upvotes: 0
Reputation: 125604
put this in the old site htaccess file
Redirect 301 / http://www.newsite.com/
this is a good link to learn about this :
http://www.webweaver.nu/html-tips/web-redirection.shtml
Upvotes: 6
Reputation: 6177
What about this solution:
RewriteRule (.*) http://new.domain.com/$1 [R=301,L]
Upvotes: -1