歡迎來到小豬圈!

2008-10-13

Apache 子網域對應

  • 以下是使用 Apache HTTP Server 的 mod_vhost_alias 模組。
  • 假設擁有的網域和 IP 是: example.com 與 256.256.256.256 。
  • 在 DNS 新增一筆泛解“*”: * IN A 256.256.256.256
  • 泛解“*”是標準語法,而且不會覆蓋已設定的域名。參見 Wildcard DNS record - Wikipedia, the free encyclopedia
  • 意思是指 example.com 的子網域 (像 www.example.com 或 ftp.example.com 之類的) 全部對應到 256.256.256.256 。
  • 在 Apache httpd.conf 加入:
    LoadModule vhost_alias_module modules/mod_vhost_alias.so
    UseCanonicalName Off
    VirtualDocumentRoot "C:/web/%-1/%-2/%-3"
    
  • 上述設定會使 www.example.com 對應到 C:/web/com/example/www ,或 abc.example.com 對應到 C:/web/com/example/abc …之類的效果,這樣新增子網域只要增加子目錄即可,不需重開 Server。
  • Apache 還有其它對應網域/網址的方法。參見 Mapping URLs to Filesystem Locations - Apache HTTP Server

2 comments:

  1. 謝謝版主
    解決了我的需要

    ReplyDelete
  2. 我也看到這篇,感謝您 !!

    ReplyDelete

Comment Form Message

標籤分類

Blog Archive

Labels

Google Analytics Tracking Code

About Me

My photo
Keelung, R.O.C, Taiwan
一個不學無術、混吃等死的傢伙…