【发布时间】:2021-06-25 16:45:52
【问题描述】:
我配置了角度定位并使用了他们在文档中提供的 NGINX 示例。一切正常,但是我遇到了重定向问题。我的域使用的是https,所以如果用户点击https://www.example.com,nginx 会重定向到http://www.example.com/en
因此,重定向到正确的语言位置,但改用 HTTP。
server {
listen 80;
server_name localhost;
root /www/data;
# Fallback to default language if no preference defined by browser
if ($accept_language ~ "^$") {
set $accept_language "fr";
}
# Redirect "/" to Angular app in browser's preferred language
rewrite ^/$ /$accept_language permanent;
# Everything under the Angular app is always redirected to Angular in the correct language
location ~ ^/(fr|de|en) {
try_files $uri /$1/index.html?$args;
}
}
有没有办法在下面的代码中指定它应该重定向到 HTTPS?
# Everything under the Angular app is always redirected to Angular in the correct language
location ~ ^/(fr|de|en) {
try_files $uri /$1/index.html?$args;
}
【问题讨论】:
标签: angular nginx https-redirect