10

I'm moving my site from old-domain.com to new-domain.com with exactly the same pages, e.g., if old-domain.com has a page1.html (i.e., old-domain.com/page1.html) then the new domain has the same page, i.e., new-domain.com/page1.html

I tried this in the .htaccess file:

RewriteEngine on
RewriteRule (.*) http://new-domain.com/$1 [R=301,L] 

But only while old-domain.com will redirect to new-domain.com, old-domain.com/page1.html will not redirect to new-domain.com/page1.html

Thanks!

Styxxy
  • 7,462
  • 3
  • 40
  • 45
Christopher Skyi
  • 229
  • 1
  • 3
  • 12

3 Answers3

18
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

See here for more solutions: http://enarion.net/web/htaccess/migrate-domains/

allaire
  • 5,995
  • 3
  • 41
  • 56
3

Try this in your htaccess

Redirect 301 / http://www.new.com/

This will redirect (and map) all your pages from http://old.com/page1 to http://new.com/page1

  • I've tried this and it doesn't work on my site. Also no luck from other developers http://stackoverflow.com/questions/15167630/301-redirect-everything-to-new-website-root-whole-site-including-sub-pages-move#comment21433867_15167630 – brightmist.co.uk Mar 04 '13 at 19:33
  • You might need to add RewriteEngine On & RewriteBase / first – sidonaldson Jul 29 '16 at 13:03
0

Try this:

RedirectPermanent / http://www.new-domain.com/
Bhavin Joshi
  • 514
  • 3
  • 12