依照下列設定方式, 即可設定成功。
##於 C:WINDOWS\system32\drivers\etc\ 修改hosts檔 ##新增 127.0.0.1 localhost 127.0.0.1 www.sample.com 127.0.0.1 help.sample.com
##於\xampp\apache\conf\extra\ 修改httpd-vhosts.conf檔 ##新增 NameVirtualHost *:80 <VirtualHost *:80> ##指定www.sample.com路徑 ServerAdmin postmaster@sample.com DocumentRoot "/xampp/htdocs/sample.com" ServerName www.sample.com ServerAlias www.sample.com ErrorLog "logs/sample.com-error.log" CustomLog "logs/sample.com-access.log" combined </VirtualHost> <VirtualHost *:80> ##指定help.sample.com路徑 ServerAdmin postmaster@sample.com DocumentRoot "/xampp/htdocs/sample.com/help" ServerName help.sample.com ServerAlias help.sample.com ErrorLog "logs/sample.com-error.log" CustomLog "logs/sample.com-access.log" combined </VirtualHost> ##避免localhost因上面設定也轉至 sample.com資料夾 <VirtualHost *:80> DocumentRoot "/xampp/htdocs/xampp" ServerName localhost </VirtualHost>
主機端設定完畢後,還需將網域的DNS解析做修改,
以上面的例子為例需設定www、help指向到那個IP地址。
參考自 阿舍的 Drupal 架站經驗談-設定 XAMPP 的虛擬主機 ( Virtual Host)
沒有留言:
張貼留言