Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a web site in my LAN, but instead of using my laptop or PC as the hostname of the web site, users should be able to use something like

I'm doing this because I want to run many web apps (2-3 copies of same app at same time) and, obviously, I cannot use the same domain name for them.

I should add that using the hosts file won't help, I tried.
I'm using:

  • Windows 7 SP1
  • XAMPP server

It's okay for me to change OS but I want to use Apache, PHP and MySQL.

share|improve this question
I only know how to do this on Linux, not Windows. I'm sure it's the same, but the config file is in a different location. But, you do need to use the hosts file, but you also need to create a virtual host in Apache to match the domain name. This is a simple section you add that ties a domain name to a local directory. – Marty Fried Apr 7 '12 at 0:16
@MartyFried OS doesn't matter to me. I can change that:-). can you explain in detail , I got nothing from comment :-( – undone Apr 7 '12 at 0:24
OK, I added an answer. Let me know if you need help, as I've set up lots of such domains. You can even make them available from the internet if you want by setting up a dynamic DNS name. – Marty Fried Apr 7 '12 at 0:56
@MartyFried thanks, I'll test it and tell you result :-) – undone Apr 7 '12 at 1:02
Alright, I'll monitor both accounts - which I do anyway. :-) – Marty Fried Apr 7 '12 at 1:33
up vote 1 down vote accepted

The reason I didn't originally answer with more detail is because I didn't know the complete answer for Windows. But since you're willing to adapt, I'll write it up here.

There are two ways to do this. One way, that many use, is to use the directory name in the URL with the PC as the name. The server PC has a default directory for websites (the one you get when you type "http://localhost" on the local machine, or the "http://computername" from another system, assuming the computer's name is "computername". So, if that directory were called "c:\www", and you put a website in "c:\www\mywebsite", then someone can get to it by entering "http://computername/mywebsite".

To do what you want, you can use the host file, along with Apache's virtual hosts, not with just the hosts file by itself. I wrote up some directions for doing this with Ubuntu, at AskUbuntu. The only difference for Windows would be the location, and possibly name, of the configuration file. It shouldn't be hard to search and find out where it is.

check out my directions on AskUbuntu, and if you have any questions, you can ask either here or there.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .