Use the LAN based IP address to access local Apache on laptop when working outside the network

apache-2.2internal-dnsipvirtualhost

<VirtualHost *:80>
  DocumentRoot "D:/Projects"
  ServerName 192.168.11.74
</VirtualHost>

Why doesn't this work ? How to access websites on the local box (Windows, Apache, MySql, PHP) which are based on IP address assigned by company's internal network which is not accessible to outside. When the laptop gets connected to internal network, all websites works, but when outside of the company network, these IP based url doesn't work even if all the code-base, development environment resides in the local Apache server on the laptop itself.

Is there a way to point 192.168.XX.XXX to 127.0.0.1

Best Answer

Option 1

Set ServerName to localhost like this:

ServerName localhost

Then access the server via

http://localhost

It will not matter what IP you have.

Option 2

First you setup VirtualHost like this:

<VirtualHost *:80>
  DocumentRoot "D:/Projects"
  ServerName projecthost
</VirtualHost>

Then on windows you can always set an IP to which "projecthost" will point to. Edit C:\Windows\system32\drivers\etc\hosts file and add:

projecthost 127.0.0.1

or

projecthost 192.168.11.74

Then access the server via

http://projecthost
Related Topic