0

I am moving a site to a new domain and need the whole structure (of subdomains and domains) to stay intact while using a 301 redirect.

http://example.com/test/page to http://example2.com/test/page

also

http://wildcard.example.com/test/page/random to http://wildcard.example2.com/test/page/random

user989990
  • 155
  • 1
  • 7
  • 14
  • I think you'll need an htaccess file for each subdomain. [You should look at this answer for the permanent redirect](http://stackoverflow.com/a/15057194/1572077) – miah Aug 08 '13 at 21:09

2 Answers2

1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^http://example.com/test/page [NC]
RewriteRule ^(.*)$ http://example2.com/test/page [L,R=301,NC]

and

RewriteEngine on
RewriteCond %{HTTP_HOST} ^http://wildcard.example.com/test/page/random [NC]
RewriteRule ^(.*)$ http://wildcard.example2.com/test/page/random [L,R=301,NC]

you can use it

Shuvo Shuvo
  • 329
  • 2
  • 15
0

The simplest solution I found was....

For the main domain:

RewriteCond %{HTTP_HOST} ^example.com [NC]

RewriteRule ^(.*)$ http://example2.com/$1 [L,R=301]

For each subdomain:

RewriteCond %{HTTP_HOST} ^each-subdomain.example.com [NC]

RewriteRule ^(.*)$ http://each-subdomain.example2.com/$1 [L,R=301]

user989990
  • 155
  • 1
  • 7
  • 14