开发者

xampp: hosting multiple sites

I have a web server running xampp. I have two domain names lets call them www.domain1.com and www.domain2.com. I 开发者_运维知识库have updated the dns settings of domain1 to point to my server which is working fine, (i.e the files for domain1 are in the htdocs folder and when i go to www.domain1.com in a browser i get the index file of these files.) What I would like to do though is have two folders in the htdocs folder (one for domain1 and one for domain2). If i change the dns settings of domain1 and domain2 to both point to my servers ip, can i then configure xampp or apache to load the right site depending on what url has been requested?

Thanks


Yes this is easy to do. You simply need to create 1 or 2 virtual hosts in apache. This is done by editing the /apache/conf/extra/httpd-vhosts.conf file in your xampp installation. The file should have the details in it that you need. Apache will need to be restarted for the changes to happen.


Yes. Its called Name-based virtual host support. Xampp runs Apache under the covers which supports this. See this article here. Basically you have to edit your apache configuration files such that you bind a domain name to a folder where the data resides. Not sure exactly how to do this on Windows, but seems like laurencek have you covered there.

See also this article on Virtual Hosting from Wikipedia


On Xampp for WINDOWS The VirtualHost config file is located on C:\xampp\apache\conf\extra\httpd-vhosts.conf, just edit it, remove the comment characters and edit the lines... just like below

DocumentRoot "D:/xampp/htdocs/yoursite" ServerName www.yoursite.com ServerAlias www.yoursite.com ErrorLog "logs/yoursite.log" CustomLog "logs/yoursite.log" combined

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜