簡體   English   中英

將https://重定向到https:// www

[英]Redirect https:// to https://www

我有一個帶有DigitalOcean的ubuntu服務器,該服務器使用forge.laravel.com管理

我在nginx.conf文件中嘗試了許多不同的方法,以將所有可能的情況重定向到我的域https://www.domain.com

https://www.domain.com = https://www.domain.com -- GREAT
http://domain.com = https://www.domain.com -- GREAT
http://www.domain.com = https://www.domain.com -- GREAT
https://domain.com = https://domain.com -- This should redirect to the www.

這是我的nginx.conf文件的一部分

    server {
        listen 80;
        server_name domain.com;
        return 301 https://www.domain.com$request_uri;
    }

    server {
        listen 80;
        server_name www.domain.com;
        return 301 https://www.domain.com$request_uri;
    }

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

    server {
        listen 443 ssl;
        server_name domain.com;
        root /home/forge/default/public;

.... other nginx.conf configuration

誰能告訴我我在做什么錯? 我嘗試了許多組合。

更換

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

server {
    listen 443 ssl;
    server_name domain.com;
    root /home/forge/default/public;

通過

server {
    listen 443 ssl;
    server_name domain.com;
    return 301 https://www.domain.com$request_uri; 
    #INSERT HERE CERTIFICATES DIRECTIVES

}

server {
    listen 443 ssl;
    server_name www.domain.com;
    root /home/forge/default/public;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM