I am trying to redirect the domain example.com to another website example.blogspot.com (which is not hosted in my server).
I had been using htaccess
and cpanel
, so it was easy to redirect. But why redirect is not working in nginx.
No effects seen with following way in the version nginx/1.15.10
and latest vesta control panel
,
Still showing the default page (index.html) generated by vesta control panel. Should I have to change in public_html ? Or restart server ?
I have edited nginx.conf
with following code.
method 1
http{
server{
listen 80;
server_name example.com www.example.com;
return 301 https://example.blogspot.com$request_uri;
}
.....
}
method 2
http{
server{
listen [::]:80;
listen 80;
server_name example.com www.example.com;
return 301 https://example.blogspot.com$request_uri;
}
.....
}
method 3
http{
server {
server_name .example.com;
return 301 $scheme://example.blogspot.com;
}
....
}
restarting ngix after save
sudo service nginx restart
sudo systemctl restart nginx