无法让我的子域名正常工作

无法让我的子域名正常工作

我的主网站运行正常,但我尝试设置子域名,但它总是显示主网站,我已将 apache2.conf 的主要部分复制到下面

# Include the virtual host configurations:
Listen 80

# This is the "main" server running on 67.208.112.97
DocumentRoot /var/www

# This is the other address
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www
ServerName giantpixels.com.au
<Directory “/var/www”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/gardenbook/wwwroot/gardenbook
ServerName garden.giantpixels.com.au
<Directory “/home/gardenbook/wwwroot/gardenbook”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

答案1

您不能混合使用 VirtualHosts 和非 VirtualHosts。DocumentRoot从主 Apache httpd 配置中删除该指令并添加默认VirtualHost块:

# Include the virtual host configurations:
Listen 80

# This is the other address
NameVirtualHost *:80

# This VirtualHost will also be served when no Host
# header was provided or the hostname is unknown.
# See
#  http://httpd.apache.org/docs/2.2/vhosts/details.html
<VirtualHost *:80>
  DocumentRoot /var/www
  ServerName giantpixels.com.au
  <Directory “/var/www”>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /home/gardenbook/wwwroot/gardenbook
  ServerName garden.giantpixels.com.au
  <Directory “/home/gardenbook/wwwroot/gardenbook”>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

相关内容