38 Comments


  1. Nice one. This would have come in handy a couple months ago. My biggest problem with running WP multi-site on my local dev box and using subdirectories has always been with creating links like /contact-us/ that send you back to the main site. This looks like it would have been a perfect solution had I not just left my windows machine.

    I’ll be passing this on the the WordPress Vegas meetup group. I’m sure they’ll dig it!

    Reply

    1. For sure! What are you using for your Apple now? Built in Apache or MAMMP, because I think MAMP Pro allows domain mapping through there UI.

      Reply

  2. Hands Down, I just did this. Although I am using MAMP PRO!

    But I learn a lot from you austin

    Reply

  3. Thank you Austin, just what was I looking for. After testing all different config, finally found the solution for Win7. Thanks :)

    Reply

  4. Can we make it work with Domain mapping as well? I understand this is a further step than subdomains, but would be really cool if I could set up domain mapping on XAMPP.

    Reply
  5. Marcelo Rocha

    Cool tutorial. I have tried your procedure above but was getting error when was trying to access the sub-domains: when I tried to login to the first site created the page was redirected to the login page again and I can’t access the dashboard…
    After making some tests, reading more information in some forums finally I got it working fine in this way, step-by-step:
    1) After install Xampp I created the directory for the multisite, called mult.dev
    2) Then I have installed the WordPress with the Network in that directory
    3) In the httpd-vhosts.conf file I placed the following code:
    NameVirtualHost *:80

    DocumentRoot “J:/xampp/htdocs”
    ServerName localhost

    DocumentRoot “J:/xampp/htdocs/mult.dev”
    ServerName mult.dev
    ServerAlias *.mult.dev

    Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all

    4) For the “hosts” file I added the following code:
    127.0.0.1 mult.dev
    127.0.0.1 siteone.mult.dev #that would be the first site to be created
    5) Then I came back to the Network admin area and created the “siteone” there. After, everything goes perfect.
    Thanks too much for your help! :-)

    Reply

  6. i have this

    DocumentRoot “C:/xampp/htdocs”
    ServerName localhost

    DocumentRoot “C:/xampp/htdocs/wordpress”
    ServerName wordpress.dev

    Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all

    but my adress still like this -> http://wordpress.dev/wordpress/

    Reply

    1. Reply

  7. I believe that this is just the ticket! Thanks for posting and with great precision.

    I am looking to add a multi-site WordPress network to my development environment and researching how to do the setup. This post is a good gateway.

    Silly question perhaps, but can this work on earlier versions of Windows (e.g., Vista) or is something peculiar to Windows 7? Hope to bypass Windows 7 with my next upgrade. :)

    Reply

  8. Its also worth mentioning that you might need to modify the httpd.conf manually so that the below in enabled:
    Include conf/extra/httpd-vhosts.conf

    Reply
  9. Dave

    I tried this and Apache just hangs when I try to start it. I am new to Apache, and all I need to do is change my DocumentRoot to “C:/xampp/htdocs/wordpress/wp-content” instead of “C:/xampp/htdocs” that Apache uses. I can access “C:/xampp/htdocs” locally if I need to.

    How can I do this with out all the virtual crap?

    Reply
  10. unde

    thanks for the help really helped me to, this comment I’m taduciendo with a translator because I do not understand English, so it was really great but very helpful.

    unde_peru_2013

    Reply
  11. MrBrad

    With windows vista 64 – I could not find a directory called
    C:/Windows/System32/drivers/etc/hosts
    even searching there was nothing called hosts

    should I just create the new sub dirs and the hosts file?

    Reply

  12. Great article Austin – looks like I just need to change my URLs in the database and it’ll work perfectly for me.

    I do a lot of testing on other computers (Macs, other Windows machines with older browsers, etc.) so I have set myself up with a static internal IP so I can look at the site anywhere within our network.

    Rather than localhost/project it’s 192.168.0.206/project.

    Any idea how I’d accomplish this for my IP address, rather than just localhost/… ?

    If I find a solution for this, I’ll let you know.

    Reply

    1. I found the solution to this. in the same hosts file (C:/Windows/System32/drivers/etc/hosts) you can put in your direct IP address on another computer (my dev computer is 192.168.0.206) and point the the same virtualhost domain to it!

      ie.

      192.168.0.206 eateryengine.dev

      Reply
  13. Ajay Gadhavana

    thanks for help, now i want to create this in linux fedora then how this possible. its same or difference.

    Reply

  14. WordPress site moving problem is about absolute url and absolute paths stored in database.
    This method help about absolute urls…
    Are there similar method about absolute paths?

    Thank you

    Reply
  15. Naod

    I have done everything just the way put above. But Apache could not start.
    Any solution?

    Thanks

    Reply
    1. Naod

      The problem is solved, drupal was not properly installed!

      Reply
  16. Alex

    I had an issue saving the hosts file, its asking me to save as. Anyone have any suggestions?

    Reply
    1. Alex

      Aaaand, never mind. Changed the files permissions for my account and worked perfectly! Great article!

      Reply
  17. Alex

    New issue, cant get apache to start back up. Attached vhost.config below.

    NameVirtualHost *:80
    
    
        ServerAdmin [email protected]
        DocumentRoot "C:/Users/Alex/Dropbox/Web Design/Htdocs"
        ServerName dropbox.localhost
        ServerAlias dropbox.localhost
        
            Options Indexes FollowSymLinks Includes ExecCGI
            Order allow,deny
            Allow from all
    

    Any help would be greatly appreciated.

    Reply
  18. Ahmad Zain

    also you must check your httpd.conf for
    # Virtual hosts
    #Include etc/extra/httpd-vhosts.conf

    to uncomment this line

    Include etc/extra/httpd-vhosts.conf

    Thanks

    Reply
    1. rediaN

      Thanks! This bit of information was left out everywhere. Uncommenting “Include etc/extra/httpd-vhosts.conf” in the httpd.conf finally SOLVED my problem!

      Reply
  19. Joe Mayo

    modified the http-vhosts file like so:
    NameVirtualHost *:80

    ServerAdmin [email protected]
    DocumentRoot C:/xampp/htdocs/medPlatform_compressor_DB2″
    ServerName sanome.dev
    ServerAlias sanome.dev

    Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all

    ServerAdmin [email protected]
    DocumentRoot C:/xampp/htdocs/medPlatform_compressor_DB2″
    ServerName sanome.dev
    ServerAlias sanome.dev

    Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all

    Verified that the http.conf file has the vhost file included.

    Also the the host file has the following:

    127.0.0.1 localhost
    127.0.0.1 sanome.dev #change to match your Virtual Host.
    127.0.0.1 demo.sanome.dev #manually add new sub-domains.

    Apache won’t start up now. What did I do wrong or am I missing something?

    Thanks

    Reply
  20. Nad

    Thanks for the great tutorial. Here is what I’ve done.

    in file hosts

    ——–
    # localhost name resolution is handled within DNS itself.
    127.0.0.1 localhost
    127.0.0.1 dev.mysite.com
    ——–

    and in httpd-vhosts.conf

    ——–
    NameVirtualHost *:80

    DocumentRoot “D:\xampp\htdocs”
    ServerName localhost
    ServerAlias localhost

    DocumentRoot “D:\xampp\htdocs\www\dev2″
    ServerName dev.mysite.com
    ServerAlias dev.mysite.com

    Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all

    ——–

    When I give dev.mysite.com in the browser url, it does not give any error and simply redirects me to “http://localhost/www/dev2″ displaying my site properly, but displaying “http://localhost/www/dev2″ in the URL, which defeats the whole purpose of virtual hosts. What am I doing wrong here? Anyone? Many thanks in advance.

    Reply
  21. asif

    nice article but i perform all of above steps but my vitual host still not functioning it is giving error server not found

    NameVirtualHost *:80
    
        DocumentRoot C:/xampp/htdocs 
        ServerName localhost
        ServerAlias localhost
        
            Options Indexes FollowSymLinks Includes ExecCGI
            Order allow,deny
            Allow from all
        
    
    
        DocumentRoot C:/xampp/htdocs/frostbox 
        ServerName zend.localhost
        ServerAlias zend.localhost
        
            Order allow,deny
            Allow from all
        
    
    
    
    # 	127.0.0.1 zend.localhost
    

    can you help me?

    Reply
  22. Adeleke Ademolu

    Thanks for these. I’ve been looking for a way to set this up but none of the ones I’ve seen didn’t work. This finally did it. Thanks a million.

    Reply

  23. Dear Austin,

    I found this wamp server easy to implement virtual hosts:
    UWamp server, and this server you could develop using sqlite database successfuly, in others solutions the sqlite database creation demands extra configurations.

    Try this and write your impressions about, I migrate all projects from Xampp to UWamp.

    The only work tedious to do is update all hosts files from the local network statrions to use the virtual host name associated with the IP Address Fixed to access the local intranet. If the user don’t want use de IP Address to access the intranet site. It’s a hard work for great lans (above 20 stations).

    http://www.uwamp.com try you will like.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>