Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect all traffic to root of another domain

I have a domain that's not to be used anymore. I want to redirect all from http://www.old.com/ to http://www.new.com/, no matter what page the user's attempted to access on www.old.com.

Doing this:

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

is fine for the root, but other pages would do this:

http://www.old.com/cms -> http://www.new.com/cms

whereas I'd want it to go to the root, no matter what.

like image 611
Scott Brown Avatar asked Jan 11 '12 13:01

Scott Brown


People also ask

How do I permanently redirect a URL?

To redirect a site permanently, one should use a 301 redirect. This type of redirect is best for SEO purposes and also informs the search engines that the site has moved permanently. If you change your domain name and want to point to a different URL, a 301 redirect is your best choice.


1 Answers

From http://www.webconfs.com/how-to-redirect-a-webpage.php I'd say you can use the following configuration

Don't redirect subfolders/files (as you wanted): www.example.com/demo/ -> www.newexampledomain.com

Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/ [R=301,L] 

Redirect to subfolders/files: www.example.com/demo/ -> www.newexampledomain.com/demo/

Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] 
like image 198
Indrek Avatar answered Oct 02 '22 11:10

Indrek