[英]How to redirect from old domain to new domain on nginx
I currently have a domain https://dongyhuynhtantrieu.com and now I want to convert it to https://bacsicare.com , how do I do it? 我目前有一个域名https://dongyhuynhtantrieu.com ,现在我想将其转换为https://bacsicare.com ,我该怎么做? I'm currently using wordpress and nginx.
我目前正在使用wordpress和nginx。 I tried the code but it didn't work.
我尝试了代码,但它没有用。
server {
server_name www.example.com;
rewrite ^ http://example.com$request_uri? permanent;
} }
You can use return : 你可以使用return :
server {
listen 80;
server_name old_domain.com www.old_domain.com;
return 301 http://new_domain.com$request_uri?;
}
Or if inside server block: 或者如果在服务器块内:
if ($request_uri = / ) {
rewrite (.*) http://new_domain.com/ permanent;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.