一切都指向我设置的子域。
我的虚拟主机文件一定有问题,因为我很确定 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>
最佳答案
你需要这个虚拟主机:<VirtualHost sub.mydomain.com:80>
关于apache - 尽管有多个虚拟主机,但所有流量都定向到单个目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24345126/