如何在两个域上运行一个项目?
我的尝试:(但没有用,只是第一次mydomain.com
有效)
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias mydomain.com *.mydomain.com
Alias /static/ /home/ubuntu/myproject/myproject/static/
DocumentRoot /home/ubuntu/myproject/myproject
WSGIScriptAlias / /home/ubuntu/myproject/myproject/index.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName otherdomain.com
ServerAlias otherdomain.com *.otherdomain.com
Alias /static/ /home/ubuntu/myproject/myproject/static/
DocumentRoot /home/ubuntu/myproject/myproject
WSGIScriptAlias / /home/ubuntu/myproject/myproject/index.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
答案1
来自 apache 文档:
<VirtualHost *:80>
ServerName server.domain.com
ServerAlias server server2.domain.com server2
ServerAlias *.example.com
UseCanonicalName Off
# ...
</VirtualHost>