views:

659

answers:

4

Hi,

.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

A: 

What about this solution:

RewriteRule (.*) http://new.domain.com/$1 [R=301,L]
merkuro
RewriteRule is overkill when all you need is a plain old redirection
Vinko Vrsalovic
Aren't you loosing all the path/file/parameter info, if you are just using a trivial redirect?
merkuro
no, Redirect does all that
Vinko Vrsalovic
+1  A: 

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

Haim Evgi
Thanks for your help.
MarkF
if its help you ,set is as the right answer , your welcome
Haim Evgi
A: 

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.

Hippo
Maybe he wants to be able to redirect users coming from existing links to the new site, but at the same time tell all search engines that the old domain will be abandoned shortly. Basically a grace period in between everyone can slowly clear there databases.
merkuro
Hi,that's basically it, except I want to keep www.domain.com as the adverised url for the site.
MarkF
A: 

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.

Simone Carletti
thanks, the redirect statement looks like the one! I also want to also resolve any canonicalizaton issues; would that go bfore or after the ReDirectMatch statement? Thanks, Mark
MarkF
Could you be more specific? What do you mean with "resolve any canonicalizaton issues"?
Simone Carletti
At the moment I don't have anything in htaccess to help resolve www I believe Google prefers this? I was wondering what instruction I would use and whether it would come before or after the ReDirectMach instruction?
MarkF
http://www.webmasterworld.com/apache/3223535.htm
Simone Carletti