我不确定要搜索什么,但这就是我想要实现的目标。
我在某处注册了一个域名。我在其他地方也有专用的Linux服务器。我正在该Linux服务器上运行一个网站(Apache/PHP(,现在我可以通过以下途径访问:
http://[my server ip address]/subfolder-1/index.php
我将域名的 DNS 设置更改为 Linux 服务器的 IP 地址。现在,当我转到我的域名时,它实际上将index.php
加载到:http://[my server ip address]
。
我知道我可以在 Aapache 中做一些事情,以便它知道用户何时来自www.mydomain.com
,它应该显示位于以下位置的站点:
http://[my server ip address]/subfolder-1/index.php
当我来自www.my-otherdomain.com
时,它应该从以下位置加载站点:
http://[my server ip address]/subfolder-2/index.php
但我不确定要寻找什么以及如何称呼它?如何为此配置我的 Apache 服务器?
您需要像这样为 Apache 上的每个域设置虚拟主机:
<VirtualHost *:80>
ServerAdmin admin@test.com
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/test.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
之后重新加载服务器:
sudo service apache2 restart