ALTVisual
ALTVisual

Reputation: 116

htaccess Redirect same page on sub domain

I'm going to be moving my site from a root domain (mysite.com) to a suy-domain on the same server (new.mysite.com)

I have about 2,000 pages that are indexed and ranked in Google and I don't want to loose them. How can I redirect requests from the main domain, to the same page on the sub domain? The structure of the sub domain will be exactly the same as the root domain, so if someone goes to mysite.com/products/widget1, then I need to redirect them to new.mysite.com/products/widget1.

All pages are in a sub directory as well, so the redirect just needs to apply to all links in that sub directory.

Any help would be greatly appreciated.

Thanks

Upvotes: 0

Views: 178

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

To redirect all requests from olddomain to newdomain without loosing your google rank, you can use the following 301 Permanent Redirect :

RewriteEngine on


RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [NE,L,R=301]

This will permanently redirect your oldsite to the newsite telling search engines to reindex their databases with the newdomain.

Upvotes: 1

Related Questions