我想有這樣的情況:創建通配符子域名使用Apache虛擬主機
如果使用該URL用戶請求:
example.com
或www.example.com
, 用戶將看到index.php
此目錄中/home/admin1/public_html/
但當用戶請求使用其他子域(通配符)時,例如:
freediscount.example.com
,用戶將在此路徑中看到index.php
:/home/admin1/public_html/userweb/freediscount.example.com
在我的主機
技術支持,建議我用這個方法:http://www.wiredstudios.com/php-programming/setting-up-wildcard-dns-for-subdomains-on-cpanel.html
基於該教程中,PHP有一個新的工作......對特定的文件夾重定向時與子域用戶的請求。我不喜歡這種方法。對我來說,如果Apache可以處理這個問題會更好。
幾乎接近我需要的是這種方法:Virtualhost For Wildcard Subdomain and Static Subdomain
,但是,我有VirtualHost
設置,如何正確地創建VirtualHost
對於這種情況有問題嗎?
這裏是我做了什麼,但沒有工作:
## I think this one is for www or without www, automatically generated with WHM
<VirtualHost xx.xx.xx.xx:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/admin1/public_html
</VirtualHost>
## Here's what I'm trying to add
<VirtualHost xx.xx.xx.xx:80>
ServerName example.com
DocumentRoot /home/admin1/public_html/userweb/*
</VirtualHost>
截至今日爲止的鏈接。 – kontur