基于Apache的动态子域
给定一个用户名,我想“动态”创建一个子域 我把答案读了一遍 虽然它很好,但它对我不起作用,(我想),因为我的服务器上有多个域(我在这里问了我的初始问题) 我的设置是基于Apache的动态子域,apache,subdomain,Apache,Subdomain,给定一个用户名,我想“动态”创建一个子域 我把答案读了一遍 虽然它很好,但它对我不起作用,(我想),因为我的服务器上有多个域(我在这里问了我的初始问题) 我的设置是 Linode VPS 阿帕奇 Ubuntu 我有多个域名 abc.com def.com 我希望我的动态子域位于第二个域(例如x.def.com、y.def.com) 因此,我通过DNS管理器创建了一个通配符DNS条目 但由于“abc.com”是第一个配置的域,它似乎在以“x.def.com”的形式对任何子域进行“全面覆盖
- Linode VPS
- 阿帕奇
- Ubuntu
- abc.com
- def.com
# in file /apache2/sites-available/abc.com
<VirtualHost *:80>
ServerName www.abc.com
DirectoryIndex index.php index.html
DocumentRoot /home/website/public/abc.com/public/
</VirtualHost>
# in file /apache2/sites-available/def.com
<VirtualHost *:80>
ServerName www.def.com
ServerAlias *.def.com
UseCanonicalName Off
DirectoryIndex index.php index.html
DocumentRoot /home/website/public/def.com/public/
</VirtualHost>
#文件/apache2/sites available/abc.com
服务器名www.abc.com
DirectoryIndex.php index.html
DocumentRoot/home/website/public/abc.com/public/
#文件/apache2/sites available/def.com中
服务器名www.def.com
ServerAlias*.def.com
UseCononicalName关闭
DirectoryIndex.php index.html
DocumentRoot/home/website/public/def.com/public/
我觉得这个配置还可以。确保在主apache配置文件中设置了NameVirtualHost*:80
。如果你正在使用Ubuntu,这可能在ports.conf中
您可以使用
apachectl-S
检查所有配置的虚拟主机。如果设置正确,这应该包含您的通配符别名。您可以发布当前的VirtualHost配置吗?您需要正确设置ServerAlias,它才能拾取通配符子域。