<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Vhosts on Coinidea's Blog</title><link>https://blog.coinidea.com/en/tags/vhosts/</link><description>Recent content in Vhosts on Coinidea's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sat, 23 May 2015 05:34:23 +0000</lastBuildDate><atom:link href="https://blog.coinidea.com/en/tags/vhosts/index.xml" rel="self" type="application/rss+xml"/><item><title>[Apache] Virtual Host Configuration for Multi-Domain Access to Local PHP Projects</title><link>https://blog.coinidea.com/en/p/apache-virtual-host-configuration-for-multi-domain-access-to-local-php-projects/</link><pubDate>Sat, 23 May 2015 05:34:23 +0000</pubDate><guid>https://blog.coinidea.com/en/p/apache-virtual-host-configuration-for-multi-domain-access-to-local-php-projects/</guid><description>&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First, modify the hosts file located at C:\WINDOWS\system32\drivers\etc. Open it with Notepad and add:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;127.0.0.1 www.a.com
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;127.0.0.1 www.b.com
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open the file xampp\apache\conf\httpd.conf, search for &amp;ldquo;Include conf/extra/httpd-vhosts.conf&amp;rdquo;, and make sure there is no # comment symbol in front of it &amp;ndash; this ensures the vhosts virtual host configuration file is included.&lt;/p&gt;
&lt;p&gt;Once httpd-vhosts.conf is enabled, the default httpd.conf configuration becomes inactive (make sure virtual host configuration is also enabled in httpd-vhosts.conf, see step 3). All domain requests to this IP will be directed to the first virtual host in vhosts.conf.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the virtual host configuration file xampp\apache\conf\extra\httpd-vhosts.conf:&lt;br&gt;
Remove the ## before NameVirtualHost *:80 to enable vhosts.conf. The default httpd.conf configuration becomes inactive, and virtual host settings will only be configured in httpd-vhosts.conf.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DocumentRoot /xampp/htdocs/a
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ServerName www.a.com
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DocumentRoot /xampp/htdocs/b
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ServerName www.b.com
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After completing step 3, you will notice that accessing localhost redirects to the path configured for site a. This is explained in step 2 &amp;ndash; once vhosts is enabled, the default httpd configuration becomes inactive, and the default access points to the first entry in vhosts. To fix this, you need to add the localhost directory configuration back.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DocumentRoot /xampp/htdocs/
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ServerName localhost
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With this, the XAMPP virtual host setup is complete. Now accessing localhost still shows the original XAMPP welcome page, accessing &lt;a class="link" href="https://www.a.com" target="_blank" rel="noopener"
&gt;www.a.com&lt;/a&gt; points to the bound directory a, and accessing &lt;a class="link" href="https://www.b.com" target="_blank" rel="noopener"
&gt;www.b.com&lt;/a&gt; points to the bound directory b.&lt;/p&gt;</description></item></channel></rss>