2016-12-05 3 views
1

私はNginxの "default" vhostとして次のようなものを使用しています。すべてのサブドメインには基本的に独自のディレクトリが必要です。Nginxワイルドカードルートのサブドメインからのフォールバック

誰でもフォールバックを助けることができます(これは初めてです)。ディレクトリ/サブドメインが存在しない場合は、カスタムのある種の404.htmlページが必要です。

ありがとうございます!

server { 

    server_name ~^(.+).mysite.com$; 

    set $root_path $1; 

    root /var/www/$root_path/public; 
    index index.html index.php; 

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

    location ~ \.php$ { 
     #Include Nginx’s fastcgi configuration 
     include /etc/nginx/fastcgi.conf; 
     #Look for the FastCGI Process Manager at this location 
     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     client_max_body_size 100m; 
    } 

} 

答えて

0

これを試してみてください:

server { 
... 
    error_page 404 /your_custom_404.html; 
    location = /your_custom_404.html { 
     root /path/to/your_custom_404.html; 
     internal; 
    } 

    location/{ 
     try_files $uri $uri/ /index.php?$args =404; 
    } 
... 
} 
関連する問題