apache - 尽管有多个虚拟主机,但所有流量都定向到单个目录

标签 apache ubuntu virtualhost ubuntu-14.04

一切都指向我设置的子域。

我的虚拟主机文件一定有问题,因为我很确定 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/

相关文章:

php - htaccess 使用 GET 请求重定向

python - importerror 没有名为缓存的模块

shell - 将挂载的服务器添加到 Ubuntu 文件管理器侧面板

virtualhost - apache virtualhost SSL +非SSL

php - .htaccess 在本地主机上给出 500 错误

Apache subversion LDAP 组访问 1 个存储库内的每个文件夹

ruby - therubyracer v8 init.so 段错误

python - 无法在 virtualenv 中导入 beautifulsoup4

jakarta-ee - 野蝇/暗流 : Multiple aliases for one host

angular - Docker的Apache CORS header