title: How to access multiple virtual hosts in my localhost from my mobile phone/another machine
body: <p>I'm creating an android app that uses 2 virtual hosts. One for the api and one for the repository of all the images uploaded in my app. I can access one of them without using virtual hosts and through my laptop's IP address only. But I want to access them both through virtual hosts so that I dont have to change it when I upload it to the  live server. Please help me how to do it. </p>
  
  <p>Here's the snippet of my XAMPP "httpd-vhosts.conf" file:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      DocumentRoot "C:/xampp/htdocs/myprojectapi"
      ServerName api.mydomain.com
      ServerAlias api.mydomain.com
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      DocumentRoot "C:/xampp/htdocs/myimages"
      ServerName images.mydomain.com
      ServerAlias images.mydomain.com
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>and heres the snippet of my windows "hosts" file:</p>
  
  <pre><code>127.0.0.1 api.mydomain.com
  127.0.0.1 images.mydomain.com
  </code></pre>
  
  <p>I can only access one of them from my android phone but only through my laptop's IP address and if i comment out one of the vhosts:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      DocumentRoot "C:/xampp/htdocs/myprojectapi"
      ServerName api.mydomain.com
      ServerAlias api.mydomain.com
  &lt;/VirtualHost&gt;
  
  #&lt;VirtualHost *:80&gt;
  #    DocumentRoot "C:/xampp/htdocs/myimages"
  #    ServerName images.mydomain.com
  #   ServerAlias images.mydomain.com
  #&lt;/VirtualHost&gt;
  </code></pre>
  
  <p>and my hosts file: </p>
  
  <pre><code>127.0.0.1 api.mydomain.com
  #127.0.0.1 images.mydomain.com
  </code></pre>
  
  <p>but in order for my app to work properly i need to access the two projects through Named Virtual Hosts at the same time. What should I do to make this work? Please help.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Im already using different ports but it still won't work.</p>
  
  <p>Here's the snippet of my updated vhost file:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      DocumentRoot "C:/xampp/htdocs/myprojectapi"
      ServerName api.mydomain.com
      ServerAlias api.mydomain.com
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:8081&gt;
      DocumentRoot "C:/xampp/htdocs/myimages"
      ServerName images.mydomain.com
      ServerAlias images.mydomain.com
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>and heres the snippet in my updated hosts file: </p>
  
  <pre><code>192.168.2.5 api.mydomain.com
  192.168.2.5 images.mydomain.com
  </code></pre>