tags:

views:

296

answers:

3

Basically what I run now on my home PC is one of these WAMP in a box applications so I can write my PHP code and use a MySQL database. That is all fine, but I run a lot of websites so now I have a folder I've called /~WEBSITES/ where I put everything making the URLs to these http://localhost/~WEBSITES/domain.com/ -- what I'd like is to be able to type http://local.domain.com/ into my address bar and have it point to my local drive, but I don't want this for everyone, just me.

Possible?

NOTE: I've running Windows XP

+2  A: 

Modify the text file named "hosts" found in C:\Windows\system32\drivers\etc\

Suppose you want to point www.mycustomer.com to your local host. Add in:

127.0.0.1 www.mycustomer.com

HardCode
I considered responding with the same, but that won't help him - he wants his 'local.domain.com' to point to a specific virtual folder, not just to his local computer. Using your answerhe'd still have to type: http://www.mycustomer.com/~WEBSITES/domain.com
Erik Forbes
Ya you're right Erik, I thought it was something I was doing wrong, but what you said worked
Andrew G. Johnson
I think you'd want to only create local.*, of www.*, entries in the hosts file.
overslacked
He could also install a real name server on his machine. After all, BIND runs on MS-Windows.
bortzmeyer
+2  A: 

You'll need to setup virtual hosts in apache (not IIS... oops), and combine that with HardCode's answer. That should do what you need.

Andrew
Not running IIS...
Andrew G. Johnson
What server are you running? Almost any webserver worth its code will allow you to setup multiple domains.
Andrew
w*A*mp = Apache. The thing is I don't want the domain pointing there so if my visitors type in local.domain.com they will be pointed to themselves. I want it to be only on my computer or my home network or whatever
Andrew G. Johnson
Sorry. I missed that somehow. Then all you need to do is setup virtual hosts in Apache. This will not affect anyone unless they do the hosts file trick because there is no DNS entry for the domain (or it is pointing to the production server). You want to set the domain in your hosts file.
Andrew
+2  A: 

You'll need to setup virtual hosts with Apache, and combine that with HardCode's answer (setting your hosts file). That should do what you need.

AUTHOR EDIT: Great article, here's the quick notes on what to do (at least with the most recent version of apache2triad as your WAMP installer)

Add to C:\APACHE_INSTALL_DIRECTORY\conf\httpd.conf:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain1.com"
    ServerName local.domain1.com
</VirtualHost>
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain2.com"
    ServerName local.domain2.com
</VirtualHost>

Add to C:\Windows\system32\drivers\etc\hosts

127.0.0.1   localhost
127.0.0.1   local.domain1.com
127.0.0.1   local.domain2.com
davr
Did you just copy my exact answer and replace IIS with Apache?
Andrew
Andrew, I think you just described what I am looking for lol.
Andrew G. Johnson
yeah...pretty much...
davr