Ruby on rails nginx url从www重定向到https的无www
我一直在搜索将我的网站从www.domain.com重定向到domain.com 我跟着这个 但正常情况下,它会重定向到domain.com 但当我尝试时,它保持原样,而不是重定向到 我不知道我错过了什么Ruby on rails nginx url从www重定向到https的无www,ruby-on-rails,url,redirect,nginx,Ruby On Rails,Url,Redirect,Nginx,我一直在搜索将我的网站从www.domain.com重定向到domain.com 我跟着这个 但正常情况下,它会重定向到domain.com 但当我尝试时,它保持原样,而不是重定向到 我不知道我错过了什么 server { listen 80; server_name www.domain.com; // $scheme will get the http protocol // and 301 is best practice for tablet, phone
server {
listen 80;
server_name www.domain.com;
// $scheme will get the http protocol
// and 301 is best practice for tablet, phone, desktop and seo
return 301 $scheme://domain.com$request_uri;
}
server {
listen 80;
server_name domain.com;
// here goes the rest of your config file
// example
location / {
rewrite ^/cp/login?$ /cp/login.php last;
// etc etc...
}
}
您需要设置另一台服务器来侦听https并重定向它
server {
listen 443 ssl;
server_name www.example.com;
# add ssl config to avoid certificate warning
return 301 https://example.com;
}
您可以将http和https重定向合并到一台服务器中
server {
listen 80 443;
server_name www.example.com;
ssl on;
# ssl config
return 301 $scheme://example.com;
}
您需要设置另一台服务器来侦听https并重定向它
server {
listen 443 ssl;
server_name www.example.com;
# add ssl config to avoid certificate warning
return 301 https://example.com;
}
您可以将http和https重定向合并到一台服务器中
server {
listen 80 443;
server_name www.example.com;
ssl on;
# ssl config
return 301 $scheme://example.com;
}
请考虑发布你的NGNIX配置文件。我在第一个答案后面跟着AcktKy,我已经编辑了我从Link KoSO中得到的一个问题,然后你可能在错误的端口上听到HTTPS,下面的答案很简单。请考虑发布你的NGIX配置。我已经编辑了我的问题,我在linkSo中遵循了哪一个,那么你可能在错误的端口上收听https,下面的答案非常简单。