Set up multiple virtual hosts on XAMPP for windows

As I work on many projects and experiments on my local Windows development environment (XAMPP), I normally put all web stuff in the htdocs directory and usually I’m happy with it. For several projects (like CMS installations or experiments with frameworks) it’s very handy to have a separated virtual host in order to be able to have an own document root for that application. You just don’t have to bug with different paths and subdirectories and can focus on developing instead of setting base URLs etc.

For example, if I develop MVC applications which are meant to run in a host’s document root, I want to work with paths like http://<host>/<controller>/<action> without having to deal with subdirectories like http://<host>/directory/subdirectory/public/<controller>/<action>.

It just facilitates developing and even tough it’s a little more work at setting up a new project, usually it’s worth it. Here’s a quick and dirty how to achieve this in two steps.

1. Create the virtual host entries

This HowTo is based on the actual version (1.6.7) of XAMPP. As XAMPP is prepared for what we want to do, you just have to edit the following file:
X:\<path to your xampp installation>\apache\conf\extra\httpd-vhosts.conf.

First of all, uncomment the following line to enable name based virtual host on your server’s port 80:

NameVirtualHost *:80

Then you can start adding your virtual hosts. The following listing is a skeleton of what I usually use. I will assume we create a project which should be accessible by entering http://testproject in your browser’s address bar.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot D:/srv/xampp/projects/testproject/public
    ServerName testproject

    <Directory "D:/srv/xampp/projects/testproject/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Just make sure the DocumentRoot exists and matches the Directory and remember the value you set for ServerName.

2. Edit your Windows hosts file

Now that your apache is ready to go, you have to tell your system what to do if you enter http://testproject in your browser. The most simple way without having to deal with DNS or anything else is to edit your hosts file you can find here (should be obvious that you have to alter the path if you got Windows installed elsewhere): C:\Windows\system32\drivers\etc.

The file is just a simple text file which contains IP-to-hostname mappings. Edit the file with a text editor and append a new line which maps the hostname you specified in apache’s ServerName-directive to 127.0.0.1. You can place it just under the existing one which defines localhost. In the end, your file could look like this:

# some comment stuff

127.0.0.1       localhost
127.0.0.1       testproject

Done

Save the file and you should be done. Remember to restart your apache in order to load the new configuration. If all went fine, you should land on your virtual host if you enter the specified hostname in your browser.

If XAMPP doesn’t start anymore or your server is not reachable, take a look at the error log and check the apache config file(s) for typos or errors.

Update: I forgot to mention, that you lose access to your default htdocs directory by following the steps above. To fix this, you have to create an extra vhost with ServerName localhost which points to your htdocs directory.

  • Ananth S

    Thanks, Mate!

  • Ananth S

    Thanks, Mate!

  • http://www.suedeapple.co.uk Paul

    Cheers for this matey! – I’ve been hunting for a simple tutorial to get this up and working.

  • http://www.suedeapple.co.uk Paul

    Cheers for this matey! – I’ve been hunting for a simple tutorial to get this up and working.

  • http://maff.ailoo.net/ Mathias

    You’re welcome, I’m glad I could help :)

  • http://maff.ailoo.net/ Mathias

    You’re welcome, I’m glad I could help :)

  • Djordje

    I never comment on blogs, but this is so simple and efficient that I have to say: Awesome!

    Thanks Mathias

  • Djordje

    I never comment on blogs, but this is so simple and efficient that I have to say: Awesome!

    Thanks Mathias

  • James

    I need help

    I have done all this then when I go to the URL i get

    “Access forbidden”

    ?? Why is this ??

  • James

    I need help

    I have done all this then when I go to the URL i get

    “Access forbidden”

    ?? Why is this ??

  • http://maff.ailoo.net/ Mathias

    James,

    most likely the document root you specified does not exist, try re-checking your paths.

    Did you use the same vhost skeleton as in the post (including the Indexes option)? If not, your server might just miss an index file.

    Take a look at the error log, you should find more information to your problem there. You can find it here:

    <xampp dir>apachelogserror.log

  • http://maff.ailoo.net/ Mathias

    James,

    most likely the document root you specified does not exist, try re-checking your paths.

    Did you use the same vhost skeleton as in the post (including the Indexes option)? If not, your server might just miss an index file.

    Take a look at the error log, you should find more information to your problem there. You can find it here:

    <xampp dir>\apache\logs\error.log
  • http://mestizo.tv alas

    thanks for your post, it help me to get vhost done

    regards

  • http://mestizo.tv alas

    thanks for your post, it help me to get vhost done

    regards

  • chavex

    Thanks…..exelent….very very good

  • chavex

    Thanks…..exelent….very very good

  • http://maff.ailoo.net/ Mathias

    Thanks mate :)

  • http://maff.ailoo.net/ Mathias

    Thanks mate :)

  • http://pelmeshkin.com Erik

    Sweet! I didn’t uncomment the NameVirtualHost *:80 and was scratching my head for a while, but your post saved me.

    Cheers.

  • http://pelmeshkin.com Erik

    Sweet! I didn’t uncomment the NameVirtualHost *:80 and was scratching my head for a while, but your post saved me.

    Cheers.

  • need help

    I coudln’t get it work, please help.

    httpd-vhosts.conf file
    NameVirtualHost *:126
    <VirtualHost *:126>
    ServerAdmin webmaster@localhost
    DocumentRoot D:/xampp/htdocs/flickrwall
    ServerName flickrwall

    <Directory “D:/xampp/htdocs/flickrwall”>
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    <Directory>
    <VirtualHost>

    hosts file
    127.0.0.1 localhost
    127.0.0.1:126 flickrwall

    If I test it with 127.0.0.1:126 or localhost:126, it works.

    but if I try flickrwall or flickrwall:126, it doesn’t work.

    please help me to debug it, thank you.

  • need help

    I coudln’t get it work, please help.

    httpd-vhosts.conf file

    NameVirtualHost *:126
    <VirtualHost *:126>
    	ServerAdmin webmaster@localhost
    	DocumentRoot D:/xampp/htdocs/flickrwall
    	ServerName flickrwall
    
    	<Directory "D:/xampp/htdocs/flickrwall">
    		Options Indexes FollowSymLinks Includes ExecCGI
    		AllowOverride All
    		Order allow,deny
    		Allow from all
    	<Directory>
    <VirtualHost>

    hosts file

    127.0.0.1       localhost
    127.0.0.1:126       flickrwall

    If I test it with 127.0.0.1:126 or localhost:126, it works.

    but if I try flickrwall or flickrwall:126, it doesn’t work.

    please help me to debug it, thank you.

  • http://maff.ailoo.net/ Mathias

    The problem is that you can’t specify ports in the hosts file. You can just map hostnames to ip-addresses. Is it necessary to use another port than the standard port 80? If so you could create a vhost on port 80 which redirects all requests to your other vhost running on port 126 (e.g. via mod_rewrite or PHP).

  • http://maff.ailoo.net/ Mathias

    The problem is that you can’t specify ports in the hosts file. You can just map hostnames to ip-addresses. Is it necessary to use another port than the standard port 80? If so you could create a vhost on port 80 which redirects all requests to your other vhost running on port 126 (e.g. via mod_rewrite or PHP).

  • need help

    hi, Mathias. thanks for help. I also have iis 5.1 installed for my asp.net. that one using part 80. now I changed IIS port number to 88.

    and make my apache server using 80.

    again same problem. localhost working, but if i m using the servername testproject, then its not working.

    NameVirtualHost *:80
    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot D:/xampp/htdocs/flickrwall
    ServerName testproject

    <Directory “D:/xampp/htdocs/flickrwall”>
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>

    127.0.0.1 localhost
    127.0.0.1 testproject

    in my httpd.conf file, #LoadModule vhost_alias_module modules/mod_vhost_alias.so, do I need to uncomment this line?

  • need help

    hi, Mathias. thanks for help. I also have iis 5.1 installed for my asp.net. that one using part 80. now I changed IIS port number to 88.

    and make my apache server using 80.

    again same problem. localhost working, but if i m using the servername testproject, then its not working.

    NameVirtualHost *:80
    <VirtualHost *:80>
    	ServerAdmin webmaster@localhost
    	DocumentRoot D:/xampp/htdocs/flickrwall
    	ServerName testproject
    
        <Directory "D:/xampp/htdocs/flickrwall">
    		Options Indexes FollowSymLinks Includes ExecCGI
    		AllowOverride All
    		Order allow,deny
    		Allow from all
        </Directory>
    </VirtualHost>
    127.0.0.1       localhost
    127.0.0.1       testproject
    

    in my httpd.conf file, #LoadModule vhost_alias_module modules/mod_vhost_alias.so, do I need to uncomment this line?

  • need help

    its me again. ignore my last question, I made a stupid mistake, now its working, great tutorial, thank you so much.

    • disqus_3gbGJoHvEZ

      what is ur mistake here?

  • need help

    its me again. ignore my last question, I made a stupid mistake, now its working, great tutorial, thank you so much.

  • http://maff.ailoo.net/ Mathias

    Hehe, I’m glad it works for you :)

  • http://maff.ailoo.net/ Mathias

    Hehe, I’m glad it works for you :)

  • SS

    Thank you verymuch, it is very simple and easy guide which work without any crazy errors. Keep up the good work.

  • SS

    Thank you verymuch, it is very simple and easy guide which work without any crazy errors. Keep up the good work.

  • http://www.runwalsoft.com Manish Runwal

    Cool…this is simple and easies way.
    Thanks.
    Manish Runwal
    http://Runwalsoft.com

  • http://www.runwalsoft.com Manish Runwal

    Cool…this is simple and easies way.
    Thanks.
    Manish Runwal
    http://Runwalsoft.com

  • http://www.graphicdetail.com Bruce Sauls

    Thanks. This really made it easy.

  • http://www.graphicdetail.com Bruce Sauls

    Thanks. This really made it easy.

  • Pingback: Recent URLs tagged Xampp - Urlrecorder()

  • Danforth

    Very useful guide – thanks!

    A note for people doing this on a new Vista machine, which only has Notepad for text editing: Notepad doesn’t run at admin level, even if you are an admin user, so if you use Notepad to edit the hosts file, it won’t work. All will appear will until you try to save your changes, at which point you’ll be told the system can’t find the file you’re actually editing.

    Right click on the Notepad shortcut, and you can run it as an administrator. Now you can make the changes you need.

    This only applies to the hosts file, presumably because of its location. The httpd-vhosts.conf file can be edited without admin priveleges.

    Or do what I do, and go see your boss about getting a product key for a proper text editor :)

  • Danforth

    Very useful guide – thanks!

    A note for people doing this on a new Vista machine, which only has Notepad for text editing: Notepad doesn’t run at admin level, even if you are an admin user, so if you use Notepad to edit the hosts file, it won’t work. All will appear will until you try to save your changes, at which point you’ll be told the system can’t find the file you’re actually editing.

    Right click on the Notepad shortcut, and you can run it as an administrator. Now you can make the changes you need.

    This only applies to the hosts file, presumably because of its location. The httpd-vhosts.conf file can be edited without admin priveleges.

    Or do what I do, and go see your boss about getting a product key for a proper text editor :)

  • http://maff.ailoo.net/ Mathias

    Danforth, thanks for your addition :) never tried this on Vista.

  • http://maff.ailoo.net/ Mathias

    Danforth, thanks for your addition :) never tried this on Vista.

  • Pingback: Bookmarks about Host()

  • Basit

    what if i wanted to setup *.testproject (like wildcard subdomains, how can i do that, one of the project requires wildcard for username, so i wanted to do that, anyone can help on this? please.

  • Basit

    what if i wanted to setup *.testproject (like wildcard subdomains, how can i do that, one of the project requires wildcard for username, so i wanted to do that, anyone can help on this? please.

  • http://maff.ailoo.net/ Mathias

    @Basit:
    For Apache’s part something like this should work:

    <VirtualHost *:80>
    ServerName testproject
    ServerAlias *.testproject

    […]
    </VirtualHost>

  • http://maff.ailoo.net/ Mathias

    @Basit:
    For Apache’s part something like this should work:

    <VirtualHost *:80>
    	ServerName testproject
    	ServerAlias *.testproject
    
    	[...]
    </VirtualHost>
  • Pingback: Настройка виртуальных хостов для XAMPP в Windows XP « Потусторонним В()

  • jeet

    will this work with wamp.
    Thanks

  • jeet

    will this work with wamp.
    Thanks

  • Pingback: Websites tagged "xampp" on Postsaver()

  • Nathan

    I have tried this, but it doesn’t seem to matter what I do; when I type in “http://sacramento” (for example), the page that loads is the same that I get when I type in “http://localhost”: it redirects to “http://[hostname]/xampp/” and shows me the XAMPP welcome screen.

    I have tried it both the way that you outline, and the way outlined by David Powers in “Dreamweaver CS4 with CSS, Ajax, and PHP”. It comes out the same either way, and I am tearing my hair out. HELP!!!

    For reference’s sake, here’s the relevant code:

    1.
    # Use name-based virtual hosting.
    #
    NameVirtualHost *:80

    2.

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs
    ServerName localhost

    <Directory “C:/xampp/htdocs”>
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>

    <VirtualHost *:80>
    ServerAdmin webmaster@sacramento
    DocumentRoot C:/xampp/vhosts/sacramento
    ServerName sacramento

    <Directory “C:/xampp/vhosts/sacramento”>
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>

    (Both from httpd-vhosts.conf)

    3.
    # For example:
    #
    # 102.54.94.97 rhino.acme.com # source server
    # 38.25.63.10 x.acme.com # x client host

    127.0.0.1 localhost
    127.0.0.1 sacramento

    (From C:WINDOWSsystem32driversetchosts)

  • Nathan

    I have tried this, but it doesn’t seem to matter what I do; when I type in “http://sacramento” (for example), the page that loads is the same that I get when I type in “http://localhost”: it redirects to “http://[hostname]/xampp/” and shows me the XAMPP welcome screen.

    I have tried it both the way that you outline, and the way outlined by David Powers in “Dreamweaver CS4 with CSS, Ajax, and PHP”. It comes out the same either way, and I am tearing my hair out. HELP!!!

    For reference’s sake, here’s the relevant code:

    1.

    # Use name-based virtual hosting.
    #
    NameVirtualHost *:80

    2.

    <VirtualHost *:80>
      ServerAdmin webmaster@localhost
      DocumentRoot C:/xampp/htdocs
      ServerName localhost
    
      <Directory "C:/xampp/htdocs">    
    	Options Indexes FollowSymLinks Includes ExecCGI
    	AllowOverride All
    	Order allow,deny
    	Allow from all
      </Directory>     
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerAdmin webmaster@sacramento
      DocumentRoot C:/xampp/vhosts/sacramento
      ServerName sacramento
    
      <Directory "C:/xampp/vhosts/sacramento">    
    	Options Indexes FollowSymLinks Includes ExecCGI
    	AllowOverride All
    	Order allow,deny
    	Allow from all
      </Directory>     
    </VirtualHost>    
    

    (Both from httpd-vhosts.conf)

    3.

    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    
    127.0.0.1       localhost
    127.0.0.1	sacramento

    (From C:\WINDOWS\system32\drivers\etc\hosts)

  • Nathan

    Okay, nevermind, I am SUCH a dork…

  • Nathan

    Okay, nevermind, I am SUCH a dork…

  • http://maff.ailoo.net/ Mathias

    So, what was the problem Nathan? ;)

  • http://maff.ailoo.net/ Mathias

    So, what was the problem Nathan? ;)

  • Basit

    lol i actually came to help nathan, when i saw his email.

    its working fine, but there is index.php file, which redirecting the page to localhost/xampp/ delete that file and you will get what you wanted. :)

  • Basit

    lol i actually came to help nathan, when i saw his email.

    its working fine, but there is index.php file, which redirecting the page to localhost/xampp/ delete that file and you will get what you wanted. :)

  • Bernard

    Great tutorial but im having a problem similar to what Nathan had and its driving me crazy.Help would be major appreciated.Im doing this on a mac with leopard running XAMPP 0.7.4

    httpd-vhosts.conf

    <code NameVirtualHost *:80

    DocumentRoot /Dream/Applications.xamppfiles/htdocs/site
    ServerName personal.dev

    ErrorLog logs/site.log
    CustomLog logs/access-ge.log combined

    I run XAMPP in debug mode which confirmed that the file paths are right,however the page still redirects to the xampp index page. I tried deleting it as Nathan suggested but the error the site returned was “The requested URL /xampp/index.php was not found on this server.”

    Can you help :(
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all

    hosts file


    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost

    #mystuff
    127.0.0.1 personal.dev

  • Bernard

    Great tutorial but im having a problem similar to what Nathan had and its driving me crazy.Help would be major appreciated.Im doing this on a mac with leopard running XAMPP 0.7.4

    httpd-vhosts.conf

    <code NameVirtualHost *:80

    DocumentRoot /Dream/Applications.xamppfiles/htdocs/site
    ServerName personal.dev

    ErrorLog logs/site.log
    CustomLog logs/access-ge.log combined

    I run XAMPP in debug mode which confirmed that the file paths are right,however the page still redirects to the xampp index page. I tried deleting it as Nathan suggested but the error the site returned was “The requested URL /xampp/index.php was not found on this server.”

    Can you help :(
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all

    hosts file


    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost

    #mystuff
    127.0.0.1 personal.dev

  • http://Basit.me Basit

    you have installed correctly and its working fine, like i said in previous post.

    its not anything to do with configuration. its the index.php file inside htdocs folder. try renaming “index.php” to “xampp.php” and also “.html” too.

    then try again, it will load perfectly with the http://Your-New-Host/.

    they should have not hard coded the redirection path, anyway, try going to xampp.php and you will see it will redirect to localhost again, well you have to change that from php coding from “localhost” to $_SERVER[‘HTTP_HOST’], save it and try accessing again, and it will redirect to http://Your-New-Host/xampp/

    i hope this helps and i hope people dont ask for it again lol.. but good luck :)

  • http://Basit.me Basit

    you have installed correctly and its working fine, like i said in previous post.

    its not anything to do with configuration. its the index.php file inside htdocs folder. try renaming “index.php” to “xampp.php” and also “.html” too.

    then try again, it will load perfectly with the http://Your-New-Host/.

    they should have not hard coded the redirection path, anyway, try going to xampp.php and you will see it will redirect to localhost again, well you have to change that from php coding from “localhost” to $_SERVER[‘HTTP_HOST’], save it and try accessing again, and it will redirect to http://Your-New-Host/xampp/

    i hope this helps and i hope people dont ask for it again lol.. but good luck :)

  • http://maff.ailoo.net/ Mathias

    Hey Basit, thanks for your support :)

  • http://maff.ailoo.net/ Mathias

    Hey Basit, thanks for your support :)

  • http://www.b-os.co.za david Albino

    Wahooo thanks for teaching

  • http://www.b-os.co.za david Albino

    Wahooo thanks for teaching

  • tom

    I tried everything but I get the message document root does not exist when I try to restart the apache service

  • tom

    I tried everything but I get the message document root does not exist when I try to restart the apache service

  • http://maff.ailoo.net/ Mathias

    @tom: have you checked that Directory and DocumentRoot point to the correct path? Does the path exist? Does your user have access to that directory? Which OS are you using?

  • http://maff.ailoo.net/ Mathias

    @tom: have you checked that Directory and DocumentRoot point to the correct path? Does the path exist? Does your user have access to that directory? Which OS are you using?

  • http://www.s3solutions.nl Vincent

    This drives me nuts!
    What a crap that redirection to xampp/index.php.
    I cannot get it to work on Leopard with Xampp 0.7.4 not even when renaming the file, after deleting the cache.
    It seems almost less time consuming to compile everything from scratch.
    Does anyone have the final hint?

  • http://www.s3solutions.nl Vincent

    This drives me nuts!
    What a crap that redirection to xampp/index.php.
    I cannot get it to work on Leopard with Xampp 0.7.4 not even when renaming the file, after deleting the cache.
    It seems almost less time consuming to compile everything from scratch.
    Does anyone have the final hint?

  • Pingback: Introduction et installation de CodeIgniter (partie 1)()

  • magoo

    Thanks mate, searching for XAMPP Virtual Hosts returns a lot of chunk. Sorting that all out leaves your page for the best :-)

    Cheers
    magoo

  • magoo

    Thanks mate, searching for XAMPP Virtual Hosts returns a lot of chunk. Sorting that all out leaves your page for the best :-)

    Cheers
    magoo

  • nubian

    Hi, how about if I use a directory which is not under X:/xampp/htdocs?
    e.g. Y:/localweb ?

    Any tips?

  • nubian

    Hi, how about if I use a directory which is not under X:/xampp/htdocs?
    e.g. Y:/localweb ?

    Any tips?

  • magoo

    @nubian:
    Works like a charm. I got the XAMPP htdocs directory set in my apache-config, but most of my projects reside in a other directory below my userfiles in Vista. Just use the actual directory in the VHOST.

  • magoo

    @nubian:
    Works like a charm. I got the XAMPP htdocs directory set in my apache-config, but most of my projects reside in a other directory below my userfiles in Vista. Just use the actual directory in the VHOST.

  • http://jganesh.com Jay

    how do i execute/run .php files which are not in htdocs folder… is there are work around… i did google and found some stuff which aren’t in my terms… i will be great if you could get me a fix on this… thanks, Jay

  • http://jganesh.com Jay

    how do i execute/run .php files which are not in htdocs folder… is there are work around… i did google and found some stuff which aren’t in my terms… i will be great if you could get me a fix on this… thanks, Jay

  • http://www.Basit.me Basit

    yes jay you can do it same from virtual host and lets say, call http://basit, which you can set folder to c:/xampp/basit or any other folder path.

    i recommand you to first setup this virtual host and then try changing things around it, it will be good experience.

  • http://www.Basit.me Basit

    yes jay you can do it same from virtual host and lets say, call http://basit, which you can set folder to c:/xampp/basit or any other folder path.

    i recommand you to first setup this virtual host and then try changing things around it, it will be good experience.

  • http://jganesh.com Jay

    Thanks Basit… it worked :)

  • http://jganesh.com Jay

    Thanks Basit… it worked :)

  • dewasalju

    i have succesfully setup the virtual host and managed to install joomla and can be access by others pc in my network.

    the problem is i cannot install other joomla or cms like aTutor.. when click localhost, it directed to my first joomla site..

    someone please advice. thank you

    • http://maff.ailoo.net/ Mathias

      how does your config look like? Do you use localhost as ServerName for all hosts? Name-based virtual hosts get distinguished by name…

  • dewasalju

    i have succesfully setup the virtual host and managed to install joomla and can be access by others pc in my network.

    the problem is i cannot install other joomla or cms like aTutor.. when click localhost, it directed to my first joomla site..

    someone please advice. thank you

    • http://maff.ailoo.net/ Mathias

      how does your config look like? Do you use localhost as ServerName for all hosts? Name-based virtual hosts get distinguished by name…

  • magoo

    @dewasalju

    What you want to do is to setup several VHOSTS. For Example your main Joomla app has the VHOST joomla1.dewasalju.dyndns.org.

    Now just create another VHOST for joomla2. Incoming requests for that hostname will then be served with that respective DocumentRoot.

  • magoo

    @dewasalju

    What you want to do is to setup several VHOSTS. For Example your main Joomla app has the VHOST joomla1.dewasalju.dyndns.org.

    Now just create another VHOST for joomla2. Incoming requests for that hostname will then be served with that respective DocumentRoot.

  • Arjan

    I have a virtual host setup like in your tutorial, but now I run into the following:
    I have setup XAMPP, and added a virtual host for a project. Xampp lives in D:xampp, and my DocumentRoot for the virtual host is in D:wwwprojectA.
    When I put a static html in the folder, http://projectA.local works fine, but when I put want to use this with a CMS (Drupal, so uses PHP, MySQL connection) in there, I just get a blank page…

    Any clue what the reason for that is? Something to do with PHP?

    • http://maff.ailoo.net/ Mathias

      @Arjan strange, does the same thing happen when you just put there a PHP file which echoes something or calls phpinfo()? Are there any new entries in your logfiles (access.log, error.log) when you access the hosts? Do you have any services/programs running that might listen to port 80 (Skype is such a candidate)? PHP shouldn’t be the problem as it is loaded as Apache module and should be available throughout all virtual hosts.

  • Arjan

    I have a virtual host setup like in your tutorial, but now I run into the following:
    I have setup XAMPP, and added a virtual host for a project. Xampp lives in D:\xampp, and my DocumentRoot for the virtual host is in D:\www\projectA.
    When I put a static html in the folder, http://projectA.local works fine, but when I put want to use this with a CMS (Drupal, so uses PHP, MySQL connection) in there, I just get a blank page…

    Any clue what the reason for that is? Something to do with PHP?

    • http://maff.ailoo.net/ Mathias

      @Arjan strange, does the same thing happen when you just put there a PHP file which echoes something or calls phpinfo()? Are there any new entries in your logfiles (access.log, error.log) when you access the hosts? Do you have any services/programs running that might listen to port 80 (Skype is such a candidate)? PHP shouldn’t be the problem as it is loaded as Apache module and should be available throughout all virtual hosts.

  • Rhys

    I have yet to utilize this system, but will be testing it out today. Seems like its just what I’m after.

    Just a quick one, in your opinion what is the best method for MySQL databases in this situation? Will this allow a unique phpMyAdmin for each different directory I create / is this possible?

    This will work great for keeping my projects apart, but I’m keen to keep databases seperate also.

    • http://maff.ailoo.net/ Mathias

      @Rhys as Adrjan wrote, you just need to set the right permissions in your MySQL databases. If you create a user which has only access to a specific database, he will not see any other DBs when loggin into phpMyAdmin. Example:

      “`sql
      CREATE DATABASE myproject;
      GRANT ALL PRIVILEGES ON myproject.* to myuser@localhost IDENTIFIED BY “secretpassword”;
      “`

  • Rhys

    I have yet to utilize this system, but will be testing it out today. Seems like its just what I’m after.

    Just a quick one, in your opinion what is the best method for MySQL databases in this situation? Will this allow a unique phpMyAdmin for each different directory I create / is this possible?

    This will work great for keeping my projects apart, but I’m keen to keep databases seperate also.

    • http://maff.ailoo.net/ Mathias

      @Rhys as Adrjan wrote, you just need to set the right permissions in your MySQL databases. If you create a user which has only access to a specific database, he will not see any other DBs when loggin into phpMyAdmin. Example:

      “`sql
      CREATE DATABASE myproject;
      GRANT ALL PRIVILEGES ON myproject.* to myuser@localhost IDENTIFIED BY “secretpassword”;
      “`

  • Arjan

    @Rhys: you can create different databases for each project. AFAIK the instance of phpMyAdmin is not related to a specific directory/project. Which databases you can see and manage when logged into phpMyAdmin depends on the privileges assigned to the user. So you could create a different user for each database.

  • Arjan

    @Rhys: you can create different databases for each project. AFAIK the instance of phpMyAdmin is not related to a specific directory/project. Which databases you can see and manage when logged into phpMyAdmin depends on the privileges assigned to the user. So you could create a different user for each database.

  • Arjan

    Hi Mathias, thanks for your comment. I found out my problem must be Drupal-specific. When I put a fresh Drupal install in the folder for that virtual host everything worked, so the problem I described must be with settings in the site’s setup (it’s a copy of a live site). The virtual server itself is working fine…

  • Arjan

    Hi Mathias, thanks for your comment. I found out my problem must be Drupal-specific. When I put a fresh Drupal install in the folder for that virtual host everything worked, so the problem I described must be with settings in the site’s setup (it’s a copy of a live site). The virtual server itself is working fine…

  • Ty

    Great post! Thanks for putting this together. It’s not about the shorter URLs. It’s about redirects working correctly now. Sweet!

  • Ty

    Great post! Thanks for putting this together. It’s not about the shorter URLs. It’s about redirects working correctly now. Sweet!

  • maikel

    how can internet know which host to take??

    • http://maff.ailoo.net/ Mathias

      The allmighty internet knows everything ;) If your question was serious just contact me and I’ll try to explain it in a bit more depth ;)

  • maikel

    how can internet know which host to take??

    • http://maff.ailoo.net/ Mathias

      The allmighty internet knows everything ;) If your question was serious just contact me and I’ll try to explain it in a bit more depth ;)

  • kevin

    Nathan, what was your solution? I have the same issue.. I’ve even renamed the index.html and index.php files and it is still redirecting me to the xampp directory.

    My code is exactly the same as Nathans… What did I do wrong?

  • kevin

    Nathan, what was your solution? I have the same issue.. I’ve even renamed the index.html and index.php files and it is still redirecting me to the xampp directory.

    My code is exactly the same as Nathans… What did I do wrong?

  • http://www.Basit.me Basit

    check my previous post. empty the index.php/html file and it will stop redirecting.. open it and remove all the lines and thats it :)

  • http://www.Basit.me Basit

    check my previous post. empty the index.php/html file and it will stop redirecting.. open it and remove all the lines and thats it :)

  • kevin

    For some reason, being a ‘new day’ and fresh install and mod has got it working.

    Question:
    I go to http://mysite and it works. When I click on a link, the URL changes to http://localhost/about.php.

    Also if I go to the URL “localhost”, it also shows me the “mysite” directory… is this correct?

    Its working, but it seems there is a little glitch..

  • kevin

    For some reason, being a ‘new day’ and fresh install and mod has got it working.

    Question:
    I go to http://mysite and it works. When I click on a link, the URL changes to http://localhost/about.php.

    Also if I go to the URL “localhost”, it also shows me the “mysite” directory… is this correct?

    Its working, but it seems there is a little glitch..

  • http://www.Basit.me Basit

    when you go to url localhost and it shows directory, that is correct. it happens because you dont have index.php file in the main root directory.

    about clicking on url and it changes to localhost. make sure url is “/about.php” only in the html and not with “http://localhost/about.php”. it should not change the path.

  • http://www.Basit.me Basit

    when you go to url localhost and it shows directory, that is correct. it happens because you dont have index.php file in the main root directory.

    about clicking on url and it changes to localhost. make sure url is “/about.php” only in the html and not with “http://localhost/about.php”. it should not change the path.

  • ja

    Thanks a lot for this great great tutorial, it’s working like a charm.. you made it seem so simple….

  • ja

    Thanks a lot for this great great tutorial, it’s working like a charm.. you made it seem so simple….

  • svarog

    Very well written. Tnx!

  • svarog

    Very well written. Tnx!

  • http://www.marclittlemore.com Marc

    Thanks for the tutorial Matthias! I’ve been wondering how to do this with XAMPP as I’ve got multiple web apps I’ve been working on. It works brilliantly!

  • http://www.marclittlemore.com Marc

    Thanks for the tutorial Matthias! I’ve been wondering how to do this with XAMPP as I’ve got multiple web apps I’ve been working on. It works brilliantly!

  • shetu

    Thanks, Mate!

  • http://test/eclipse//test/file.php shetu

    Thanks, Mate!

  • http://www.getupandrunning.net Mark

    Just wanted to say thanks – it worked exactly as I needed.

  • http://www.getupandrunning.net Mark

    Just wanted to say thanks – it worked exactly as I needed.

  • http://www.roderik.net/ Roderik

    Excellent, works like a charm now. Expected much more path problems but managed to set it up in minutes.

    • http://maff.ailoo.net/ Mathias

      Thanks for the feedback :)

  • http://www.roderik.net/ Roderik

    Excellent, works like a charm now. Expected much more path problems but managed to set it up in minutes.

    • http://maff.ailoo.net/ Mathias

      Thanks for the feedback :)

  • Pingback: Set up multiple virtual hosts on XAMPP for Windows « blog NSNC()

  • Dalyla

    I made these steps and my apache runs, but when I call myhost it brings xampp main page

    DocumentRoot C:/xampp/htdocs/
    ServerName localhost
    ServerAdmin admin@localhost

    ServerAdmin webmaster@localhost
    DocumentRoot C:/Development/Web/myhost
    ServerName myhost

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

    Any idea?

  • Dalyla

    I made these steps and my apache runs, but when I call myhost it brings xampp main page

    DocumentRoot C:/xampp/htdocs/
    ServerName localhost
    ServerAdmin admin@localhost

    ServerAdmin webmaster@localhost
    DocumentRoot C:/Development/Web/myhost
    ServerName myhost

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

    Any idea?

  • Paul

    Hey, Cheers for this post. It is quite helpful. I had this all working before with xampp, I have http://localhost working with two virtual hosts http://myclub.dev and http://mycharity.dev. It seems to be broken now with the config below, all query urls (localhost, mycharity and myclub) go to ‘C:/xampp/htdocs/mycharity/dev/’ directory, which is the mycharity.dev vhost dir. If I rename all virtual hosts to *:80 advised in your post instead of the below, all are redirected to ‘C:/xampp/htdocs’ being localhost directory. *:80 used to work when I had this working.

    NameVirtualHost *:80

    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs
    ServerName localhost

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

    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs/mycharity/dev/
    ServerName mycharity.dev

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

    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs/myClub/dev/web_root/
    ServerName myclub.dev

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

    My hosts file is also valid at ‘C:WindowsSystem32Driversetchosts’.

    127.0.0.1 localhost
    127.0.0.1 mycharity.dev
    127.0.0.1 myclub.dev

    Any help is greatly appreciated.

    /Paul

  • Paul

    Hey, Cheers for this post. It is quite helpful. I had this all working before with xampp, I have http://localhost working with two virtual hosts http://myclub.dev and http://mycharity.dev. It seems to be broken now with the config below, all query urls (localhost, mycharity and myclub) go to ‘C:/xampp/htdocs/mycharity/dev/’ directory, which is the mycharity.dev vhost dir. If I rename all virtual hosts to *:80 advised in your post instead of the below, all are redirected to ‘C:/xampp/htdocs’ being localhost directory. *:80 used to work when I had this working.

    NameVirtualHost *:80

    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs
    ServerName localhost

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

    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs/mycharity/dev/
    ServerName mycharity.dev

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

    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs/myClub/dev/web_root/
    ServerName myclub.dev

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

    My hosts file is also valid at ‘C:\Windows\System32\Drivers\etc\hosts’.

    127.0.0.1 localhost
    127.0.0.1 mycharity.dev
    127.0.0.1 myclub.dev

    Any help is greatly appreciated.

    /Paul

  • http://salmanamjad.co.cc Salman

    thanx alot….

  • http://salmanamjad.co.cc Salman

    thanx alot….

  • Thomas

    I am tryng to get the VHosts woeking on my Xampp Installation.

    I have to websites
    http://www.website1.co.uk
    c:/xampp/htdocs/website1

    http://www.website2.co.uk
    c:/xampp/htdocs/website2

    I have tryed everything that I can think of but when i put the VerturalHost stuff in both site direct to the same location.

    Anyhelp please.

  • Thomas

    I am tryng to get the VHosts woeking on my Xampp Installation.

    I have to websites
    http://www.website1.co.uk
    c:/xampp/htdocs/website1

    http://www.website2.co.uk
    c:/xampp/htdocs/website2

    I have tryed everything that I can think of but when i put the VerturalHost stuff in both site direct to the same location.

    Anyhelp please.

  • Sun

    hi! i want to setup 2 sites on vhost

    NameVirtualHost *:80

    DocumentRoot “C:/web”
    ServerName localhost

    ServerAdmin info@localhost
    DocumentRoot “C:/web/sitea”
    ServerName sitea.test.com

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

    ServerAdmin info@localhost
    DocumentRoot “C:/web/siteb”
    ServerName siteb.test.com

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

    This is my hosts file
    127.0.0.1 localhost
    127.0.0.1 sitea.test.com
    127.0.0.1 siteb.test.com

    It just work with the first site “sitea.test.com”

    Whats the problem? the test.com domain ?

  • Sun

    hi! i want to setup 2 sites on vhost

    NameVirtualHost *:80

    DocumentRoot “C:/web”
    ServerName localhost

    ServerAdmin info@localhost
    DocumentRoot “C:/web/sitea”
    ServerName sitea.test.com

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

    ServerAdmin info@localhost
    DocumentRoot “C:/web/siteb”
    ServerName siteb.test.com

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

    This is my hosts file
    127.0.0.1 localhost
    127.0.0.1 sitea.test.com
    127.0.0.1 siteb.test.com

    It just work with the first site “sitea.test.com”

    Whats the problem? the test.com domain ?

  • http://parkfamilyweb.co.uk/support/xampp/ Thomas

    Hi Sun,

    I found a easy fix.
    In your httpd-vhosts.config file. Put the ServerName First.

    Example

    ServerName localhost
    DocumentRoot “C:/web”

    ServServerName sitea.test.com
    ServerAdmin info@localhost
    DocumentRoot “C:/web/sitea”

  • http://parkfamilyweb.co.uk/support/xampp/ Thomas

    Hi Sun,

    I found a easy fix.
    In your httpd-vhosts.config file. Put the ServerName First.

    Example

    ServerName localhost
    DocumentRoot “C:/web”

    ServServerName sitea.test.com
    ServerAdmin info@localhost
    DocumentRoot “C:/web/sitea”

  • JamesF2

    that option you said to subdomains doesn’t work.


    ServerAlias *.site.local

    how can I make this work?

    i want to use one folder only, so docRoot should be
    only site, the domain is to be redirected to site modules.

  • JamesF2

    that option you said to subdomains doesn’t work.


    ServerAlias *.site.local

    how can I make this work?

    i want to use one folder only, so docRoot should be
    only site, the domain is to be redirected to site modules.

  • http://parkfamilyweb.co.uk/support/xampp/ Thomas

    If you wont ALL Domain to go to say C:/docroot/site
    then just change the document root file in the XAMPP Config file.

    To do this you need to declare the Domain name (test.local) in a Domain Controller or in the local Domain File.

    In the Following:
    From C:WINDOWSsystem32driversetchosts

    “`xml
    For example:
    #
    # 102.54.94.97 rhino.acme.com # source server
    # 38.25.63.10 x.acme.com # x client host

    127.0.0.1 localhost
    127.0.0.1 test.local
    “`

    iN apache/config/extra/vhost-xampp.config

    “`xml
    ServerName localhost
    DocumentRoot “C:/web”
    “`

    This should do the trick.

    If you wont more help message me.

  • http://parkfamilyweb.co.uk/support/xampp/ Thomas

    If you wont ALL Domain to go to say C:/docroot/site
    then just change the document root file in the XAMPP Config file.

    To do this you need to declare the Domain name (test.local) in a Domain Controller or in the local Domain File.

    In the Following:
    From C:\WINDOWS\system32\drivers\etc\hosts

    “`xml
    For example:
    #
    # 102.54.94.97 rhino.acme.com # source server
    # 38.25.63.10 x.acme.com # x client host

    127.0.0.1 localhost
    127.0.0.1 test.local
    “`

    iN apache/config/extra/vhost-xampp.config

    “`xml
    ServerName localhost
    DocumentRoot “C:/web”
    “`

    This should do the trick.

    If you wont more help message me.

  • http://toddzemler.com Todd

    Perfecto! Great instructions!

  • http://toddzemler.com Todd

    Perfecto! Great instructions!

  • James

    Thanks for the quick reference.

  • James

    Thanks for the quick reference.

  • David

    Brilliant quick summary. Worked first time and does exactly what I needed.

  • David

    Brilliant quick summary. Worked first time and does exactly what I needed.

  • Bernie

    I was having the same problem as Nathan. Everything was set up correctly but my site http://test kept redirecting to http://test/xampp and giving an error.

    Finally I remembered that right at the start I had copied across the index.php file from xampp into my test folder as ‘a quick and easy way to test to see if it worked’ — without checking out the contents of that index.php file. Doh!!! Replaced file and all is well.

    Posting this here just in case someone else does the same thing and can save them a few hours.

  • Bernie

    I was having the same problem as Nathan. Everything was set up correctly but my site http://test kept redirecting to http://test/xampp and giving an error.

    Finally I remembered that right at the start I had copied across the index.php file from xampp into my test folder as ‘a quick and easy way to test to see if it worked’ — without checking out the contents of that index.php file. Doh!!! Replaced file and all is well.

    Posting this here just in case someone else does the same thing and can save them a few hours.

  • http://katadrew.com Drew

    Yes! Thank you so much. This solved my troubles with relative links!

  • http://katadrew.com Drew

    Yes! Thank you so much. This solved my troubles with relative links!

  • Derek Perkins

    I’m having the same problem that Paul and Sun were having where both of my virtual hosts were being redirected to the first one. I moved the ServerName to be the first attribute and it didn’t change anything. Does anyone have a solution?

  • Derek Perkins

    I’m having the same problem that Paul and Sun were having where both of my virtual hosts were being redirected to the first one. I moved the ServerName to be the first attribute and it didn’t change anything. Does anyone have a solution?

  • Derek Perkins

    I finally found a solution that is ridiculously easy. By default, this line is commented out:

    NameVirtualHost *:80

    Uncomment the line and everything will start working how you want it to.

  • Derek Perkins

    I finally found a solution that is ridiculously easy. By default, this line is commented out:

    NameVirtualHost *:80

    Uncomment the line and everything will start working how you want it to.

  • Anand

    THANK YOU!

  • Anand

    THANK YOU!

  • Angelin Sirbu

    For those of you who didn’t manage to setup multiple virtual hosts, i found the solution.

    In your windows hosts file add:

    # My XAMPP development hosts
    127.0.0.1 example1.dev
    127.0.0.1 http://www.example1.dev

    127.0.0.1 example2.dev
    127.0.0.1 http://www.example2.dev

    In your httpd-vhosts.conf (notice that i’ve put 127.0.0.1 instead of *):

    NameVirtualHost 127.0.0.1:80

    DocumentRoot /xampp/htdocs/example1/
    ServerName http://www.example1.dev
    ServerAlias *.example1.dev

    DocumentRoot /xampp/htdocs/example2/
    ServerName http://www.example2.dev
    ServerAlias *.example2.dev

    You can add as many virtual hosts as you like.

  • Angelin Sirbu

    For those of you who didn’t manage to setup multiple virtual hosts, i found the solution.

    In your windows hosts file add:

    # My XAMPP development hosts
    127.0.0.1 example1.dev
    127.0.0.1 http://www.example1.dev

    127.0.0.1 example2.dev
    127.0.0.1 http://www.example2.dev

    In your httpd-vhosts.conf (notice that i’ve put 127.0.0.1 instead of *):

    NameVirtualHost 127.0.0.1:80

    DocumentRoot /xampp/htdocs/example1/
    ServerName http://www.example1.dev
    ServerAlias *.example1.dev

    DocumentRoot /xampp/htdocs/example2/
    ServerName http://www.example2.dev
    ServerAlias *.example2.dev

    You can add as many virtual hosts as you like.

  • Davanti

    none of the below solutions worked for me, but they helped! thanks!.
    my server always defaults to /program files/xampp/htdocs
    so when i remove the index files from that directory xampp still works, but for my sites i get a directory listing of …/htdocs which shows
    …/htdocs/xampp and …/htdocs/mywebsite
    and can then browse to the desired subfolder.
    so why is the server is not serving out of ….htdocs/mywebsite
    the example VirtualHost in the httpd-vhosts.conf file shows DocumentRoot as .”../htdocs/dummy-host2.localhost ” is that a server name or a directory??
    Peace and good luck.
    D

  • PaulaLA

    I hope this doesn’t sound terribly dumb, but I’m wondering, what does “success” looks like when the virtual hosting has been set up correctly?

    I don’t have a full-blown php site or index page to put into my c:/vhost folder, so I renamed an html file with a .php extension, and tried to set up a virtual host for that — assuming that when I typed the path into the browser — http://peacockhill/ — it would open the page. But it’s just taking me to the XAMPP for Windows “welcome” page.

    When I adjust some of the settings I get an “Ooops! File not found” message. So I’m wondering if the configuration that brings me to the XAMPP page is correct, and the reason the index file is not displaying is it’s not a “real” .php site.

    Any insight much appreciated!

    PaulaLA

    • http://ailoo.net Mathias

      The easiest way to debug virtual hosts is to create a file named index.php in the document root of the virtual host, which is calling the phpinfo function. E.g.:

      <?php phpinfo(); ?>This will show you all php settings including the current document root. Basically the configuration has nothing to do with PHP as virtual hosts are purely managed by apache itself – the phpinfo just shows you some useful info.Regards,Mathias

  • Jeferson dos Santos

    Thanks

  • http://twitter.com/KannanNadarajan KannanNadarajan

    Excellent, Thanks

  • http://profiles.google.com/ilya.bezdelev Ilya Bezdelev

    Thanks! I have been renaming my htdocs back and forth when I wanted to work on different projects.

    P.s. facebook connect button doesn’t work

  • http://twitter.com/armsiee Simon Dolding

    Ridiculously simple but incredibly useful!  Thanks.

  • Pingback: Virtual hosts on XAMPP | Kjetil Hårtveit's Wordpress Blog()

  • kjetil_runescape

    Great:)

    Btw it has probably been answered already but might as well repeat (cba reading every comment).

    If you reach the xampp homepage even if you picked a different directory, chances are that you’ve put the virtual host localhost first in the order. Simply swap your virtual directories so it precedes the localhost declaration.

  • Renátó S.

    Great writing, thanks!

    But I have a problem. Can anybody tell me how to set up dinamic subdomains? I mean: If I want to use sub-a.host.com and sub-b.host.com, and once I want to use sub-c.host.com one in a time, and i dont’t want to modify the hosts file everytime, is there any way to set something?

    I tried with the following:
    hosts:
    127.0.0.1      localhost
    127.0.0.1      host.com
    127.0.0.1      *.host.com

    http-vhosts.conf:

        ServerAdmin me@mail.com
        DocumentRoot D:/VAIO/xampp/htdocs/probe
        ServerName host.com

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

        ServerAdmin me@mail.com
        DocumentRoot D:/VAIO/xampp/htdocs/probe
        ServerName host.com
        ServerAlias *.host.com
       
       
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
       

    I using Win7 and XAMPP.

    If in the hosts file i wrote a new line like:
    127.0.0.1      sub-a.host.com
    It works.

    But how can I make it automatically?

    ps: I’m sorry for my english, i’m just learning it.

  • Pingback: Blog()

  • Renato

    Congratulations for the article, very good!

    One question, how do I access the http://localhost the default page of xampp and only through the custom url to access my project?

    I followed the tutorial but are accessing http://localhost for my project and not the root of xampp

  • Kamelsh Bar

    what if i have xampp installed on diffrent port???

  • Douglas Moore

    I edited both files but when I type in my virtual host, I get the Xampp welcome page. My document root is “C:/xampp/htdocs/mydocroot”. I’m running Xampp 1.7.7 and Winxp Pro.