nginx不使用重写剥离www
我想在我的nginx配置中从我的url中删除www,并查看我编写的以下配置的文档和堆栈溢出帖子,但它似乎不起作用nginx不使用重写剥离www,nginx,Nginx,我想在我的nginx配置中从我的url中删除www,并查看我编写的以下配置的文档和堆栈溢出帖子,但它似乎不起作用 server_name { server_name www.subdomain.domain.com; rewrite ^(.*) https://subdomain.domain.com/$1 permanent } server_name { server_name subdomain.domain.
server_name {
server_name www.subdomain.domain.com;
rewrite ^(.*) https://subdomain.domain.com/$1 permanent
}
server_name {
server_name subdomain.domain.com;
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /file;
index index.html index.htm app.js;
location /{
proxy_pass https://subdomain.domain.com:443/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /*/ {
proxy_pass https://subdomain.domain.com:443/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /404.html;
}
但它似乎根本不起作用。但是,每当我尝试使用www.subdomain.domain.com访问该网站时,我都无法访问该网站,但效果良好。关于这方面的任何建议都将非常感谢。您在nginx config server\u name server中有输入错误,请尝试返回,而不是以更正确的方式重写:
server {
server_name www.subdomain.domain.com;
return 301 $scheme://subdomain.domain.com$request_uri;
}
您有许多语法错误。你重启nginx了吗?