[英]How to get all URLs redirect to HTTPS in Nginx , except this one
我已經可以使用301重定向了,但是我需要保留一個網址格式,因此它由http提供。 現在我用這個:
server {
listen 80 default;
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}
我在返回之前嘗試了這個:
location /wp-json {
return 301 http://www.example.com$request_uri;
}
但這沒有幫助。 我需要以http://www.example.com/wp-json/ *開頭的任何URL都不能通過HTTPS重定向。
嘗試這個:
server {
listen 80 default;
server_name example.com www.example.com;
# Redirect to HTTPS, unless it begins with /wp-json/
if ($uri !~* "^/wp-json/") {
return 301 https://www.example.com$request_uri;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.