2017-11-27 13 views
0

私はAWS EC2でウェブサイトをホストしています。ウェブサイトのすべてのサブドメインが同じフォルダ、つまり/ var/www/html/laravel /次のように公開します:達成するには? server_name、* .example.comの前にワイルドカードを入れてみましたが、うまくいきません。どのように同じを達成するには?すべてのサブドメインをAWS EC2の同じフォルダにルーティングする方法

server { 
    listen 80; 
    listen [::]:80; 

    . . . 

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

    server_name example.com www.example.com *.example.com; 

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

    . . . 
} 
+0

「www.example.subdomain.com」のように見えるサブドメインは、「www.example.com」と同じコンテンツをレンダリングしますか?通常、ワイルドカードDNSを使用できるように登録する必要があるためです。 –

+0

両方とも同じコンテンツを表示します。私はそれをやりたい唯一の理由である内部論理のためにサブドメイン名を取得する必要があります。 –

答えて

1

*.domain.comのように使用してみてください:仮想ホストを持っていないすべてのサブドメインに使用される。これは、バーチャルホストを引き起こす

<VirtualHost 111.222.33.4> 
    ServerName domain.com 
    ServerAlias *.domain.com 
</VirtualHost> 

0

たちのサイト

<VirtualHost *:80> 
ServerAdmin [email protected] 
    DocumentRoot /home/test/public/ 
    ServerName test.com 
    ServerAlias www.test.com 
</VirtualHost> 

<VirtualHost *:80> 
ServerAdmin [email protected] 
    DocumentRoot /home/test/public/ 
    ServerName subdomain.test.com 
    ServerAlias www.subdomain.test.com 
</VirtualHost> 

としてテストを使用して上記の次を確認してください、すなわち、「サブドメイン」とは、単一のサブドメインのためのサンプルです。すべてのサブドメインについて、以下を使用します。

関連する問題