所有内容都指向我设置的子域名。
我的虚拟主机文件中必定存在错误,因为我非常确定DNS设置正确。
以下是主站点的虚拟主机文件:
# domain: mydomain.com
# public: /home/myusername/public/mydomain.com/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@mydomain.com
ServerName www.mydomain.com
ServerAlias mydomain.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/myusername/public/mydomain.com/public
<Directory /home/myusername/public/mydomain.com/public>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Log file locations
LogLevel debug
ErrorLog /home/myusername/public/mydomain.com/log/error.log
CustomLog /home/myusername/public/mydomain.com/log/access.log combined
</VirtualHost>
以下是子域的虚拟主机文件:
# domain: sub.mydomain.com
# public: /home/myusername/public/sub.mydomain.com/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@mydomain.com
ServerName sub.mydomain.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/myusername/public/sub.mydomain.com/public
<Directory /home/myusername/public/sub.mydomain.com/public>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Log file locations
LogLevel warn
ErrorLog /home/myusername/public/sub.mydomain.com/log/error.log
CustomLog /home/myusername/public/sub.mydomain.com/log/access.log combined
</VirtualHost>
答案 0 :(得分:3)
虚拟主机需要这个:
<VirtualHost sub.mydomain.com:80>