Connecting Tech Pros Worldwide Help | Site Map

Pseudo domain name on localhost

PRWang's Avatar
Newbie
 
Join Date: Jan 2008
Location: Korea
Posts: 1
#1: Jan 6 '08
I'm new to apache server so I'm having some challenges figuring some things out. Maybe what I want to do is not possible, but figured I would ask anyway.

I installed xampp on my HP Pavillion running Vista Ultimate (ugh!) on an external 160G usb hard drive (WD Passport). So far everything seems to be working except for FileZilla, but that is for a different forum.

I'm using Apache as a testbed before I ftp my sites to the web. I have them setup in different subdirectories indicating the web host and domain name. So, the file I'm working on now is in /htdocs/HostICan/yourturn. I can access the site by going to http://localhost/HostICan/yourturn, but is there a way I can shorten this address to something like http://yourturn.local?

I've played around with the hosts and the apache configuration files (VirtualHost) but so far am drawing a blank. Any help or ideas appreciated.

Thanks
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Jun 4 '09

re: Pseudo domain name on localhost


I just wrote a whole bunch here and, somehow, I managed to lose everything. Gah!.

Anyway, open your hosts file, on Vista this is usually located at C:/windows/System32/drivers/etc. Add the following line to it:

Expand|Select|Wrap|Line Numbers
  1. 127.0.0.1 yourturn.com
  2.  
You may see other lines in this file such as 127.0.0.1 localhost.

Save this file and close it.

Now, in the latest releases of XAMPP, they have a special file for virtual hosts - I cannot confirm this for earlier releases. This file can be located at <xampp dir>/apache/conf/etc/httpd-vhosts.conf. Open this file and add the following to it:

Expand|Select|Wrap|Line Numbers
  1. NameVirtualHost *:80
  2.  
  3. <VirtualHost *:80>
  4.  ServerName localhost
  5.  # Point to your root folder for localhost
  6.  DocumentRoot "C:\xampp\htdocs"
  7.  DirectoryIndex index.php index.html index.html index.htm index.shtml
  8. </VirtualHost>
  9.  
  10. <VirtualHost *:80>
  11.  ServerName yourturn.com
  12.  # Point to your root folder for yourturn.com
  13.  DocumentRoot "C:\xampp\htdocs\yourturn.com\htdocs"
  14.  DirectoryIndex index.php index.html index.html index.htm index.shtml
  15. </VirtualHost>
Restart apache, and navigate to http://yourturn.com. You should be greeted with the directory you specified in the virtual host.

Hope this helps,

Markus.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,733
#3: Jun 5 '09

re: Pseudo domain name on localhost


That's interesting.
I've always wondered how I could do that, but never really figured it out.

I wonder how I could do that same with a networked computer.
Like say, if I had an Apache server set up on a computer at IP 192.168.1.5, would editing my PC's hosts file be enough, or would I have to change something on the server to.

... damn. Now I won't be able to stop until I figure out a way to do that :P

Edit:
Yea. Turns out I just had to edit the hosts file on my PC. (W7)
Awesome... no more having to type IP addresses everywhere :)
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#4: Jun 6 '09

re: Pseudo domain name on localhost


Quote:

Originally Posted by Atli View Post

That's interesting.
I've always wondered how I could do that, but never really figured it out.

I wonder how I could do that same with a networked computer.
Like say, if I had an Apache server set up on a computer at IP 192.168.1.5, would editing my PC's hosts file be enough, or would I have to change something on the server to.

... damn. Now I won't be able to stop until I figure out a way to do that :P

Edit:
Yea. Turns out I just had to edit the hosts file on my PC. (W7)
Awesome... no more having to type IP addresses everywhere :)

Cool as hell, right? :P
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,733
#5: Jun 6 '09

re: Pseudo domain name on localhost


Quote:

Originally Posted by Markus View Post

Cool as hell, right? :P

Yea :D

Or wait... isn't hell supposed to be hot? :P
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#6: Jun 7 '09

re: Pseudo domain name on localhost


Quote:

Originally Posted by Atli View Post

Yea :D

Or wait... isn't hell supposed to be hot? :P

Yeah but .. only the coolest people live in hell 8)
Reply