Welcome! Log In Create A New Profile

Advanced

Need help to redirect domain.com to domain2.com (rewrite)

Posted by Francis 
Need help to redirect domain.com to domain2.com (rewrite)
January 15, 2013 06:19AM
Hello,

I'd like to redirect www.mydomain.com to www.mydomain2.com/try.html. These domains are on two differents servers.

This is what I've tried but it does not work:

if ($http_referer ~* (www.mydomain.com) ) {
return 301 http://www.mydomain2.com/try.html;
}

OR

if ($http_referer ~* (www.mydomain.com) ) {
rewrite ^ http://mydomain2.com/try.html permanent;
}

These two ways are not working, when i go to mydomain.com I stay on mydomain.com but... without the CSS... And I am not redirected to mydomain2.com/try.html

Any help appreciated.

Regards,

Francis
Re: Need help to redirect domain.com to domain2.com (rewrite)
January 16, 2013 08:52PM
try this in your configuration:

server {

listen 80;

root <path>;

server_name www.mydomain.com;

location / {
return 301 $scheme://www.mydomain2.com/try.html;
}
}

This will redirect all requests in www.mydomain.com/ to the address www.domain2.com/try.html

Do you want something like this?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 187
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready