Koerr
Koerr

Reputation: 15723

how to turn URL to the new domain?

old domain link:

http://www.old.com/aa/bb/cc.html

i want when this old link to be visiting,turn to:

http://www.new.com/aa/bb/cc.html

how to do this?

BTW: nginx or apache

Upvotes: 1

Views: 75

Answers (2)

intlect
intlect

Reputation: 113

For nginx I go with this on account that it also helps with alias domains.

if ($host != 'www.new.com' ) {
    rewrite  ^/(.*)$  http://www.new.com/$1 permanent;
}

Upvotes: 0

J. K.
J. K.

Reputation: 8368

Create a .htaccess file similar to the following and place it to the old domain root directory.

RewriteEngine On
RewriteRule ^(.*)$ http://www.new.com/$1 [R=301,QSA]

Upvotes: 2

Related Questions