2016-11-08 3 views
0

Я хочу перенаправить Эло https://example.com этих перенаправлений работает отлично:Ошибка перенаправление не-WWW к протоколу HTTPS

http://www.example.com -> https://example.com 
https://www.example.com -> https://example.com 

но не работает:

http://example.com -> https://example.com 

это мой Nginx полная конфигурация:

server { 
     server_name www.example.com; 
     return 301 https://example.com$request_uri; 
} 

server { 
     listen 80; ## listen for ipv4; this line is default and implied 
     listen [::]:80 default_server ipv6only=on; ## listen for ipv6 

     root /var/www/laravel/public; 
     index index.php index.html index.htm; 

     server_name example.com; 

     location/{ 
       try_files $uri $uri/ /index.php?$query_string; 
     } 

     location /doc/ { 
       alias /usr/share/doc/; 
       autoindex on; 
       allow 127.0.0.1; 
       allow ::1; 
       deny all; 
     } 

     error_page 404 /404.html; 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
       root /usr/share/nginx/www; 
     } 

     location ~ \.php$ { 
      try_files $uri /index.php =404; 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include fastcgi_params; 
     } 
} 

server { 
     listen 443 ssl; 

     server_name example.com; 
     add_header Strict-Transport-Security "max-age=31536000"; 

     ssl_certificate /home/user/example.com.chained.crt; 
     ssl_certificate_key /home/user/example.com.key; 
} 

Я вижу много примеров, чтобы перенаправить это, но сервер переходит к ошибке 500 и слишком много перенаправлений.

ответ

1

Добавить example.com в server_name

Надеюсь, что это поможет.

Смежные вопросы