簡體   English   中英

如何使用apache2和/或PHP創建多級子域

[英]how to create multiple level subdomains with apache2 and/or PHP

我正在尋找一種在運行Apache2.2和PHP5的服務器上擁有多級子域的方法。 理想情況下,解決方案將在Apache而不是PHP。

例如:

www.apps.example.com或test.apps.example.com

我之前在商業網站上看過這個,但是還沒有看到任何解決方案來實現這一點。 我本質上希望允許用戶在任何子域之前輸入www或只是輸入沒有www的子域。 所以x.example.com和www.x.example.com都解析到同一目錄。

我正在運行CentOS 5.4和Ubuntu 8.04,PHP 5.2.10和Apache 2.2

謝謝

您可以使用PHP語言將條目動態添加到apache配置文件中,但請記住,您生活在不確定性的邊緣

// add this to your httpd.conf
Include extra/httpd-vhosts.conf

// add this to extra/httpd-vhosts.conf
<VirtualHost *:80>
// with www prefix
DocumentRoot /www/example/x
ServerName x.example1.com
ServerAlias www.x.example1.com
</VirtualHost>

<VirtualHost *:80>
// without www prefix
DocumentRoot /www/example/x
ServerName x.example1.com
</VirtualHost>

您可以通過添加apache虛擬主機來實現。 可以在這里找到一堆很好的例子: http//httpd.apache.org/docs/2.0/vhosts/examples.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM