![虚拟主机:Sites-available/myfilename.conf 结构](https://linux22.com/image/72203/%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%EF%BC%9ASites-available%2Fmyfilename.conf%20%E7%BB%93%E6%9E%84.png)
我有网址http://mydomain1在 apache 上本地运行。现在我想做http://mydomain2也可以访问。
我在 myfilename.conf 中添加了相应的标签
<VirtualHost *:80>
ServerName mydomain2
ServerAdmin webmaster@localhost
DocumentRoot /home/myname/Documents/Workspace/mydomain2/
<Directory /home/myname/Documents/Workspace/mydomain2/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
<VirtualHost *:80>
ServerName mydomain1
ServerAdmin webmaster@localhost
DocumentRoot /home/myname/Documents/Workspace/mydomain1/
<Directory /home/myname/Documents/Workspace/mydomain1/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
我重新启动阿帕奇。
尽管如此,我仍然无法访问任何内容http://mydomain2,浏览器会将我重定向到 www.mydomain2.com。