2017-09-25 8 views
0

私は何が間違っているのか把握しようとしています。各ドメインは同じドメインに移動します。/etc/hostsに追加する必要がありますか?私は/ etc/hostsファイルと混同しています。私はこれは私のconfファイルである1つのIPVirtualhostのApacheの問題?

を持っている:

<VirtualHost *:80> 
    # The ServerName directive sets the request scheme, hostname and port that 
    # the server uses to identify itself. This is used when creating 
    # redirection URLs. In the context of virtual hosts, the ServerName 
    # specifies what hostname must appear in the request's Host: header to 
    # match this virtual host. For the default virtual host (this file) this 
    # value is not decisive as it is used as a last resort host regardless. 
    # However, you must set it for any further virtual host explicitly. 
    #ServerName www.example.com 
    ServerName petunderground.com 
    ServerAlias www.petunderground.com 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/html/catalog 

    <Directory /var/www/html/catalog> 
    AllowOverride All 
    </Directory> 

第二のドメイン

<VirtualHost *:80> 
    # The ServerName directive sets the request scheme, hostname and port that 
    # the server uses to identify itself. This is used when creating 
    # redirection URLs. In the context of virtual hosts, the ServerName 
    # specifies what hostname must appear in the request's Host: header to 
    # match this virtual host. For the default virtual host (this file) this 
    # value is not decisive as it is used as a last resort host regardless. 
    # However, you must set it for any further virtual host explicitly. 
    #ServerName www.example.com 
    ServerName giftboundgifts.com 
    ServerAlias www.giftboundgifts.com 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/html 

    <Directory /var/www/html> 
    AllowOverride All 
    </Directory> 
+0

仮想ホストの場合、apache2はサーバーエイリアス(完全ドメイン)を使用して要求を処理します。つまり、あるハンドラーのポートで 'example1.com'を指定し、別のハンドラーに同じインターフェース/マシンの同じポートで' example2.com'を指定することができます。このためには、要求にドメインを設定する必要があります。あなたのIPアドレスにDNSがない場合は、hostsファイルを編集してドメインをlocalhostに指定する必要があります。そうすれば、ブラウザがexample.comで試行したときにlocalhost apache2にルーティングされます –

答えて

0

は感謝し、それを考え出しました。/etc/hostsとの関係