[英]redirect subdomain to https - nginx web server
I need to redirect client.mysite.com to https while client.mysite.com/admin should keep http. 我需要将client.mysite.com重定向到https,而client.mysite.com/admin应该保留http。 How can I achieve that on nginx web server ? 如何在Nginx Web服务器上实现这一目标?
right now I use this for subdomain but redirects client.mysite.com/admin too : 现在,我将其用于子域,但也重定向client.mysite.com/admin:
server {
listen 80;
server_name my.domain.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
You need to do the redirection conditionally only on location /
您只需要在location /
上有条件地进行重定向
server {
listen 80;
server_name sub.example.com;
location = / {
return 301 https://example2.com$request_uri;
}
location / {
# remaining rules
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.