Accessing Apache from across a network

Using Apache's VirtualDocumentRoot directive to access your web server from another computer in your local network


If you're developing a website and you'd like to show a colleague in the same office what you're working on, free services like and make it easy to get connected to your computer from any other computer on your subnet.

However you need to configure your Apache web server to respond properly to these addresses. This implementation provides you with a zero-configuration approach to setting up projects to be accessed on your local home or workplace network.

Open the http.conf and make sure that you have mod_vhost_alias enabled and add this Virtual Host configuration.

  • etc
    • apache2
      • http.conf
# Make sure there is no hash (#) symbol in front of this next line:
LoadModule vhost_alias_module libexec/apache2/
  • etc
    • apache2
      • extra
        • httpd-vhosts.conf
<VirtualHost *:80>
  ServerAlias *
  ServerAlias *

  # Change "" to your username
  VirtualDocumentRoot "/Users/"

Next you need your computer's IP address. Open your terminal and type the following command:


If your IP address is: you can go to either one of the following URLs on another computer:


And the contents of the following directory will be served:


Extending the vhost

You can retrieve any part of the URL and use it in your VirtualDocumentRoot using the indexed parameters.

# Given the URL:
%-1.0   io
%-2.0   nip
%-3.0   1
%-4.0   0
%-5.0   168
%-6.0   192
%-7.0   project-name

Find more information about mod_vhost_alias at the Apache documentation website.