【发布时间】:2014-03-29 04:50:37
【问题描述】:
给定一个用户名,我想“动态”创建一个子域。
我在
中阅读了答案Create subdomains on the fly with .htaccess (PHP)
虽然它很好,但它不适合我,(我认为)因为我的服务器上有多个域(我在这里问了我最初的问题https://superuser.com/questions/720911/wildcard-subdomain-being-redirected-to-the-wrong-domain/720913?noredirect=1#comment923298_720913)。
我的设置是
- Linode VPS
- 阿帕奇
- Ubuntu
我有多个域
- abc.com
- def.com
我希望我的动态子域位于第二个域(例如 x.def.com、y.def.com)。
所以我通过我的 DNS 管理器创建了一个通配符 DNS 条目。
但由于“abc.com”是配置的第一个域,它似乎以“x.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>
【问题讨论】:
-
您能发布您当前的 VirtualHost 配置吗?您需要正确设置 ServerAlias 才能获取通配符子域。