Ich versuche, alle URLs auf example.com statt www.example.com umleiten. Es funktioniert wie erwartet, wenn ich www.example.com
eintippe und hit enter seine Umleitung zu https: //domain.com eingib. Aber wenn ich https: //www.example.com eintippe, geht es an https: //www.example.com, aber ich versuche, es auf https: //example.com umzuleiten. Ich habe einige Lösungen zu ähnlichen Fragen verfolgt, aber nicht funktioniert. Im Folgenden ist meine Nginx-Konfigurationsdatei.www zu nicht www redirect funktioniert nicht für https auf nginx
upstream puma {
server unix:///home/deploy/apps/myprod/shared/tmp/sockets/myprod-puma.sock;
}
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
#listen 80 default_server deferred;
#listen 80;
listen 443 default ssl;
server_name domain.com;
ssl_certificate /etc/nginx/ssl/domain.com.chained.crt;
ssl_certificate_key /etc/nginx/ssl/domain.key;
root /home/deploy/apps/myprod/current/public;
access_log /home/deploy/apps/myprod/current/log/nginx.access.log;
error_log /home/deploy/apps/myprod/current/log/nginx.error.log info;
#location ^~ /assets/ {
#gzip_static on;
#expires max;
#add_header Cache-Control public;
#}
location ^~ /(assets|fonts|swfs|images)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
}
Bitte kann jemand sagen, welche Änderungen sollte ich dies nicht www
[Diese Antwort] (http://stackoverflow.com/questions/43081780/dns-records-redirect-www-to-non-www/43089681#43089681) kann helfen. –