Используя ниже config, я могу получить доступ к http://example.com с перенаправлением https://www.example.com, но я не могу получить доступ к корневому домену с помощью https, https: // example. com показывает ошибку.
Вот мой конфигурационный файл nginx
server {
listen 80;
server_name example.com;
return 301 http://www.example..com$request_uri;
}
server {
listen 80;
server_name www.example.com;
root /srv/www/web;
index index.php;
location / {
if ($http_x_forwarded_proto != 'https') {
return 301 https://$server_name$request_uri;
}
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}