xampp: hosting multiple sites

半城伤御伤魂 提交于 2019-12-08 08:45:26

问题


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


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/4051731/xampp-hosting-multiple-sites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!