2017-03-18 3 views
0

나는 laravel 응용 프로그램을 보유하고 있으며 최근에 모든 사이트에서 자신의 암호화 된 SSL 인증서를 갱신하도록 요청했습니다.Laravel Forge Non-www에서 www로 리디렉션

나는이 사이트를 www 버전으로 리디렉션하지 않는 기본값 인 내 nginx 구성 파일을 기본값으로 갱신했습니다.

내 nginx는 누구나 내가 뭘 잘못 보았습니까?

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/domain.co.uk/before/*; 

server { 
    listen 443 ssl http2; 
    listen [::]:443 ssl http2; 
    server_name domain.co.uk; 
    root /home/forge/domain.co.uk/public; 

    # FORGE SSL (DO NOT REMOVE!) 
    ssl_certificate /etc/nginx/ssl/domain.co.uk/##/server.crt; 
    ssl_certificate_key /etc/nginx/ssl/domain.co.uk/##/server.key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers '##'; 
    ssl_prefer_server_ciphers on; 
    ssl_dhparam /etc/nginx/dhparams.pem; 

    add_header X-Frame-Options "SAMEORIGIN"; 
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php; 

    charset utf-8; 

    # FORGE CONFIG (DOT NOT REMOVE!) 
    include forge-conf/domain.co.uk/server/*; 

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

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/domain.co.uk-error.log error; 

    error_page 404 /index.php; 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/domain.co.uk/after/*; 

답변

0

하지 당신이 지금이 문제를 해결했지만 단지의 경우와/추가 참조를 위해 당신이 할 수있는 경우 또는 (하지이 이미 존재하는 경우)

만들기 : /etc/nginx/conf.d /redirect.conf

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

그런 다음 nginx를 다시 시작하십시오.

희망이 있습니다.