Info: A MacBookPro osX 10.9 Maverick with the build in Apache/2.2.29 as Development Server is used for this guide.

To test my websites on my local Development Server I always need to type the IP address from my MacBookPro into the Test Browsers e.g. so I could reach my Apache Server.

This guide should solve this Problem by putting my Apache behind the nice adresse - flyweb.localhost.

Edit: 12.12. 2017

Google Chrome is rolling out v63 that now forces all .dev domains to use HTTPS.

Change the Apache Configuration

Find the http.conf file

The default location should be /private/etc/apache2/http.conf use the Finder (CMD+G) or the Terminal to browse to the file location.

There is also a Terminal Command to reveal the location of the Apache Configuration file.

$ httpd -V

Activate mod_proxy Apache Modules

Open the http.conf file via a Text-Editor or with the Terminal.

$ sudo nano /private/etc/apache2/httpd.conf

Find the following lines and uncomment them.

LoadModule proxy_module /usr/lib/apache2/modules/
LoadModule proxy_http_module /usr/lib/apache2/modules/

Save and exit - hit CTRL + O to save the changes and exit the file with, CTRL + X.

Restart Apache Server

Type the restart command followed and your password if you get promted.

$ sudo apachectl restart

Edit User Configuration File

Open your Apache User configuration file with an Text-Editor or in Terminal. If the file or folder doesn't exist - create it where USERNAME should be your osX Username.

$ sudo nano /private/etc/apache2/users/USERNAME.conf

I added the following lines to my USERNAME.conf file. Replace the upper case words with your osX Username and SERVERNAME with anything you like e.g. flyweb.localhost. The ServerAlias setting also removes the tilde-Username from the URL.

<VirtualHost *:80>

    DocumentRoot "/Users/USERNAME/Sites"
    ServerName SERVERNAME.localhost
    ServerAlias SERVERNAME.localhost/~USERNAME

    <Directory "/Users/USERNAME/Sites">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all


And again save and exit the File (with the Terminal, hit CTRL + O and save the file, press CTRL + X to exit the file).

DNS cache

To inform/update the MacBookPro of the new Network/Servername we use the following Terminal command to clear the local DNS cache.

$ dscacheutil -flushcache

Prepare Clients with editing the hosts file

Change "hosts" File

The next step is to edit the "hosts" file, so any connection to the development server is resolved with the new VirtualHost entry - flyweb.localhost.

For osX Systems

Open the hosts file with nano via Terminal or use a Text-Editor.

$ sudo nano /private/etc/hosts

Add the following code as the last line in the file:  SERVERNAME.localhost

Any other Mac's on the Network, which want to connect to the Apache Server, need the IP address from the Development Server, instead of in the hosts file.

For Windows Systems

Go to the Task Menu and open Notepad.exe with "right-click" and choose "open as Administrator". Open the hosts file via Notepad and make the following changes.


Add the following code as the last line in the file, where 192.168.X.XX should be the IP address of the Development Server.

192.168.X.XX  SERVERNAME.localhost

Prepare Clients without editing the hosts file

Some devices like the iPad need to be jailbreaked, to make any changes to the hosts file. For this scenario a change in the settings off the local Router will help, so that the Development Server IP address, is resolved with the new VirtualHosts name.

Router Settings

This may work with any Router. I use a WRT54 with the DD-WRT Firmware. In the Control Panel, go to "Services" and edit the DNSMasq setting - Additional DNSMasq Options:


Be sure that DNSMasq and Local DNS is set to enabled.

Bonus Tips

Re-write Logs

The Apache USERNAME.conf file can also be used to activate the Apache .htaccess re-write Logs. These are very helpfull to debug any URL rewrites.

Add the following line to activate the log. The path to the rewrite.log file can be anywhere on the system. The RewriteLogLevel determines how detailed the debug information will be.

RewriteLog "/Users/USERNAME/Sites/rewrite.log RewriteLogLevel 2

Helper Script:

A nice tool which helps to automatically setup a VirtualHost on osX is Patrick Gibson's tool -

References & Documentation

Wikipedia hosts (file) -
Wikipedia Dnsmasq -
BSD General Commands Manual dscacheutil -
Apache Virtual Host -
Apache Module mod_rewrite -