Nov 21, 2009
Pages: 1, 2, 3

How To Assign A Virtual Domain Name To Your Localhost. - Assigning virtual domain names and websites to your localhost.

free web hosting

Read Latest Entries..: (Post #22) by iGuest on Sep 16 2009, 02:36 AM.
For www.mysite.web use ServerAlias How To Assign A Virtual Domain Name To Your Localhost. I was searching for this today so others might find it helpful too... If you also want to also have www.Mysite.Web you can use ServerAlias, just under 'ServerName' like this:  <VirtualHost 127.0.0.1>      ServerName mywebsite.Web            #change this virtual domain name      ServerAlias *.My...
read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > MODERATED AREA > Tutorials

How To Assign A Virtual Domain Name To Your Localhost. - Assigning virtual domain names and websites to your localhost.

xpress
How to assign a virtual domain name to your localhost.



With the help of this tutorial you can assign a virtual domain name to your localhost. That is you can access your local website with your favourite name like http://mysite.web instead of http://localhost and also you can assign different virtual domain names to different local webistes.


Requirements:
1.This tutorial is for Windows. Linux users can also use this, please follow rvalkass's instructions.

2.Apache webserver installed. It would be nice if you have WAMP server. This tutorial is based on WAMP server. But it works on any Apache server with little changes.

Procedure:

part1:

1. First go to location "C:\WINDOWS\system32\drivers\etc" directory.(or where you installed windows). Then open "hosts" file with simple text editor like notepad.

2. You'll see the following code at the end of the file.
CODE
127.0.0.1      localhost


In the next line add your virtual domain name like the example shown below.
CODE
127.0.0.1       mysite.web              #this is virtual domain name.


3. Now save the hosts file. mysite.web is just an example. You can add anything like "mywebsite.local" and you can use any extension or no extension at all. You can simply add "mysite" also

4. Now test your virtual domain. Just type http://mysite.web You must see your wamp page or webservers defalut page. If not you did something wrong. Go through the tutorial carefully.

Note: Don't use any real domain name like trap17.com or your own domain name if you have any. If you did so, you cannot access the original remote site. This is because, 127.0.0.1 is loopback address, anything with that address will never leave your computer.

Part 2:
Now second part, assigning virtual domain name to your web site in your webserver.

1. Open your httpd.conf file with Notepad. Click on WAMP icon in the tray, go to Apache menu and select httpd.conf there. You can also open the file by manually go to conf folder in Apache folder.

2. Create a new folder mysite in your C directory. And create a new web page index.html. These are for testing purposes. If you have a local website, specify the full path of website in below code.

3. Now add the following code at the end of the httpd.conf file.
CODE
NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
       ServerName localhost
       DocumentRoot "C:/wamp/www"            #this is default wamp root for websites
</VirtualHost>

<VirtualHost 127.0.0.1>
    ServerName mysite.web            #your virtual domain name
    DocumentRoot "C:/mysite"        #location of your site, no extenison needed
#the following are security settings, allow you to access directory outside the www directory
               <Directory C:/mysite>            #again location of your website
          Order Allow,Deny
          Allow from all
               </Directory>
</VirtualHost>

Save httpd.conf file. Restart your WAMP server. now type http://mysite.web. You'll see the index page of mysite.

Adding Another Virtual Domain and Website:

If you want another website, first add another virtual domain in hosts file as shown in part1.
And then copy and paste the following code at the end of httpd.conf file. Just change the virtual domain name, and locations of website.

CODE
<VirtualHost 127.0.0.1>
    ServerName mywebsite.web            #change this virtual domain name
    DocumentRoot "C:/mywebsite"            #location of your site, change this.
       <Directory C:/mywebsite>            #again location of your website, change this
                  Order Allow,Deny
                  Allow from all
       </Directory>
</VirtualHost>

You can add as many websites as you wish. Just repeat the above procedure.

IF you have any doubts about this tutorial, post them here.

 

 

 


Comment/Reply (w/o sign-up)

rvalkass
This can be applied to Linux users too actually smile.gif

The hosts file is located at /etc/hosts. The httpd.conf file varies between different distributions, but is often stored at /etc/apache2/httpd.conf. Other than those two changes, the tutorial can be followed in exactly the same way.

Comment/Reply (w/o sign-up)

xpress
QUOTE (rvalkass @ Dec 7 2008, 04:20 PM) *
This can be applied to Linux users too actually smile.gif

The hosts file is located at /etc/hosts. The httpd.conf file varies between different distributions, but is often stored at /etc/apache2/httpd.conf. Other than those two changes, the tutorial can be followed in exactly the same way.

Thanks for the information. I don't use linux that much, so I've no idea about server configurations in Linux. smile.gif
So...now Linux users can also use this tutorial as well. biggrin.gif

What about adding virtual domain names in Linux like adding it to hosts file in Windows(redirecting the localhost)? Do you have any idea?

 

 

 


Comment/Reply (w/o sign-up)

rvalkass
QUOTE (xpress @ Dec 7 2008, 11:03 AM) *
What about adding virtual domain names in Linux like adding it to hosts file in Windows(redirecting the localhost)? Do you have any idea?


The hosts file on Linux works in exactly the same way as the hosts file on Windows, so I see no reason why you couldn't. For example, this is what mine looks like:

CODE
127.0.0.1       localhost
127.0.1.1       rob-laptop

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


As far as I know it is exactly the same as a Windows one, and works in the same way.

Comment/Reply (w/o sign-up)

Lightning73
Looks nice, I looked for this when I just started developing web applications. But now I don't really see the use of this. As you're the only one who'll be able to use the virtual domain name. I just accepted localhost as the domain to use, and it's easy enough.

Correct me if I'm wrong, but even though this tutorial is great, the use of virtual domain names on localhost is useless. (I really hope I'm wrong, so I'll learn something biggrin.gif)

Comment/Reply (w/o sign-up)

xpress
QUOTE (Lightning73 @ Dec 7 2008, 07:04 PM) *
Looks nice, I looked for this when I just started developing web applications. But now I don't really see the use of this. As you're the only one who'll be able to use the virtual domain name. I just accepted localhost as the domain to use, and it's easy enough.

Correct me if I'm wrong, but even though this tutorial is great, the use of virtual domain names on localhost is useless. (I really hope I'm wrong, so I'll learn something biggrin.gif)


Even though you don't get any great benefits with virtual domain name for localhost, they are quite handy when you have multiple websites on your localhost.

For example you have two webistes in your computer, one is your general site, lets call it mysite, and you're developing another website for mail applications mymail. When you want to access these sites you have to type
http://localhost/mysite, or http://localhost/mymail. But f you have these virutal domains you can directly call them http://mysite or like that. So....it is easy to access your site and also looks informative as well.

And also if you assign a good extension to them they'll look like real domain names. So you can feel them as a real domain name for local websites. tongue.gif

Comment/Reply (w/o sign-up)

websey
Cheers express,

You always bring a good tut,

Also just one thing I use xampp is there much difference ????

Also juts one more thing how long does it take to get a *edit by jlhaslip* tut ok'd mine is taking forever and a day !

anyway nice tut

saves me typing /localhost/website all the time as i have 7 sites currently

Notice from jlhaslip:
Edit to remove questionable adjective

Comment/Reply (w/o sign-up)

xpress
QUOTE (websey @ Dec 7 2008, 10:48 PM) *
Cheers express, You always bring a good tut, Also just one thing I use xampp is there much difference ????

Thanks websey...Not much difference there with XAMPP, the procedure is same, just locate your httpd.conf file and edit it as per instructions, thats it.

Comment/Reply (w/o sign-up)

enhu
this really helps especially to me since i'm not good in typing. I named my site "mysite" very handy.

Comment/Reply (w/o sign-up)

freeflashclocks
Usefull and very complete tutorial, i also found it simple and easy to read as well as to understand its content and purpose of the same.

I actually never wanted to do this, so i also did not wanted to learn how to do this too, but if i wanted, this would be the tutorial i would choosen to learn, so if in a near future i feel the need to do this steps, this is the best tutorial to have, thank you for your effors, it must have take you quite a while to build it.

Comment/Reply (w/o sign-up)

Latest Entries

iGuest
For www.mysite.web use ServerAlias
How To Assign A Virtual Domain Name To Your Localhost.

I was searching for this today so others might find it helpful too... If you also want to also have www.Mysite.Web you can use ServerAlias, just under 'ServerName' like this:

 <VirtualHost 127.0.0.1>
     ServerName mywebsite.Web            #change this virtual domain name
     ServerAlias *.Mywebsite.Web            #change this virtual domain name

That way, you can type http://mysite.Web or http://www.Mysite.Web or indeed http://anythingwhatsoever.Mysite.Web and still be able to see your site.

By the way, instead of .Web, I like to use .Loc to signify that it's a local copy.

-Ian


Comment/Reply (w/o sign-up)

TheGuner
QUOTE (xpress @ Dec 7 2008, 06:24 AM) *
How to assign a virtual domain name to your localhost.



With the help of this tutorial you can assign a virtual domain name to your localhost. That is you can access your local website with your favourite name like http://mysite.web instead of http://localhost and also you can assign different virtual domain names to different local webistes.


Requirements:
1.This tutorial is for Windows. Linux users can also use this, please follow rvalkass's instructions.

2.Apache webserver installed. It would be nice if you have WAMP server. This tutorial is based on WAMP server. But it works on any Apache server with little changes.

Procedure:

part1:

1. First go to location "C:\WINDOWS\system32\drivers\etc" directory.(or where you installed windows). Then open "hosts" file with simple text editor like notepad.

2. You'll see the following code at the end of the file.
CODE
127.0.0.1      localhost


In the next line add your virtual domain name like the example shown below.
CODE
127.0.0.1       mysite.web              #this is virtual domain name.


3. Now save the hosts file. mysite.web is just an example. You can add anything like "mywebsite.local" and you can use any extension or no extension at all. You can simply add "mysite" also

4. Now test your virtual domain. Just type http://mysite.web You must see your wamp page or webservers defalut page. If not you did something wrong. Go through the tutorial carefully.

Note: Don't use any real domain name like trap17.com or your own domain name if you have any. If you did so, you cannot access the original remote site. This is because, 127.0.0.1 is loopback address, anything with that address will never leave your computer.

Part 2:
Now second part, assigning virtual domain name to your web site in your webserver.

1. Open your httpd.conf file with Notepad. Click on WAMP icon in the tray, go to Apache menu and select httpd.conf there. You can also open the file by manually go to conf folder in Apache folder.

2. Create a new folder mysite in your C directory. And create a new web page index.html. These are for testing purposes. If you have a local website, specify the full path of website in below code.

3. Now add the following code at the end of the httpd.conf file.
CODE
NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
        ServerName localhost
        DocumentRoot "C:/wamp/www"            #this is default wamp root for websites
</VirtualHost>

<VirtualHost 127.0.0.1>
     ServerName mysite.web            #your virtual domain name
     DocumentRoot "C:/mysite"        #location of your site, no extenison needed
#the following are security settings, allow you to access directory outside the www directory
                <Directory C:/mysite>            #again location of your website
            Order Allow,Deny
           Allow from all
                </Directory>
</VirtualHost>

Save httpd.conf file. Restart your WAMP server. now type http://mysite.web. You'll see the index page of mysite.

Adding Another Virtual Domain and Website:

If you want another website, first add another virtual domain in hosts file as shown in part1.
And then copy and paste the following code at the end of httpd.conf file. Just change the virtual domain name, and locations of website.

CODE
<VirtualHost 127.0.0.1>
     ServerName mywebsite.web            #change this virtual domain name
     DocumentRoot "C:/mywebsite"            #location of your site, change this.
        <Directory C:/mywebsite>            #again location of your website, change this
                   Order Allow,Deny
                   Allow from all
        </Directory>
</VirtualHost>

You can add as many websites as you wish. Just repeat the above procedure.

IF you have any doubts about this tutorial, post them here.


Thanks for this nice sharing can you plz also teach how to use SMTP service??

Thanks,

Comment/Reply (w/o sign-up)

MadBoy
This no is the same whit XAMPP,etc..

Comment/Reply (w/o sign-up)

iGuest
Noob has problems
How To Assign A Virtual Domain Name To Your Localhost.

I have run through your very well written process. Doing so crashes apache.

I am using xampp 1.7 on ubuntu hardy 8.1 

The only difference is that httpd.Conf in my version has a "include httpd-vhosts.Conf file line. 

If I put the virtual name code there I get 403 code forbidden. Does not matter if I change or block permissions.  

Is there somewhere else on httpd.Conf that I can change permissions. The only line I see is already set for all. 

Just learning so if it is obvious please be kind.  :)

-reply by Todd

 


Comment/Reply (w/o sign-up)

iGuest
Input on uses
How To Assign A Virtual Domain Name To Your Localhost.

Just a reply on who commented that it's not very useful, I'm masking my files in the URL, so I need to have a virtual domain for something like "http://someSite/Home" to work

 http://localhost/someSite/Home won't work.

-reply by Astral Axiom

 


Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2, 3
Similar Topics

Keywords :

  1. Installing Joomla On Local Computer(localhost)
    installing and managing joomla on your local host (13)
  2. How To Download Youtube Videos
    without softwares or websites (54)
    With this how to you'll find out how to download videos from youtube without using any software
    or website. 1. Retrieve the id video from the link (the code after ‘v=’) example:
    http://www.youtube.com/watch?v=muP9eH2p2PI => muP9eH2p2PI 2. In your favourite browser go to
    http://youtube.com/v/{ID video} example: http://youtube.com/v/muP9eH2p2PI 3. Link in the address
    bar will change. Replace ’swf/l.swf’ with ‘get_video’ and press Enter 4.
    Save your file /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="bi....
  3. How Can I Create Websites With Free Software?
    A challenge given to me by David of Essex (not David Essex) (16)
    OK I've done it! made a selection of tutorials and programs I'm Going to be making a CD with
    all this on if anyone is interested... So The Challenge! To Find Open Source/Free software and
    build a website with it Flash NO Javascript YES HTML YES PHP YES The Software KompoZer
    in the end its the best! it has ftp WYSIWYG and Raw code editing so its satisfying everyone
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> FTPcommander
    is brilliant! GIMP An excellent image editing program and as always FREE! Ok s....
  4. Creating Navigation For Html Websites
    Have a common navigation menu for the whole website! (12)
    Pre-requisite: HTML, inline frame tags 1 Attachment(.zip) included. Updates : 29-12-07: Doctype
    added in example files (Advised by jlhaslip) Designing a whole website takes a lot of planning
    and organization. Designing a proper navigation system is a basic step in building your website. If
    you are developing webpages in html you would have observed that as you go on creating pages it
    becomes difficult to maintain the links to the pages. This article will guide you in developing a
    common navigation menu for your website. It describes three ways, so if you don'....
  5. A Tutorial On How To Change Your Window's Screen Name's Icon
    (0)
    Have you ever wondered why you hae a fruity duck next to your name when you sign on to windows
    (at the windows welcome screen)? Have you ever wanted to get rid of that fruity duck? Well if
    you have and dont know how, this tutorial is for you! 1) Go to Start 2) Go to Controll Panel
    3) Find and Go To User Accounts or for others 4) Then down at the bottom look again for
    User Accounts, below "Or Pick A Controll Panel Icon" and click on it 5) Somthing Like this
    should have poped up 6) Click on Change My Picture 7) From there you can selec....
  6. Hide Names In Welcome Screen
    in XP (0)
    Annoyed by seeing many User Names in the Welcome Screen you can remove them Some times a user needs
    to be added to access a network resource but the user will not be physically logged in to your
    system. In such cases you can remove his/her name from the WelcomeScreen in Xp to do this go to
    Registry editor as normal go to HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENT
    VERSION\WINLOGON\SPECIALACCOUNTS\USERLIST\ Right click in the empty space in the right pane and
    create a new DWORD value Name this new value "Username" and enter "0" as the data value you are....
  7. How To: Change Your Website's Index File
    a simple trick using .htaccess (24)
    How To: Change Your Website's Index File a simple trick using the .htaccess file A simple
    tutorial which only involves editing one little file. Useful for those of us who have mime-typed
    extensions or who are creating lots of test design files and want an easy way to make the design
    they like best their default file. Create a file called .htaccess in the /public_html/ folder if
    you don't have it. I think one should be there already when you get your site so if it isn't
    you should create it anyway! In the file write the following: CODE Direct....
  8. How To Setup Your Own Dns (domain Name Server)
    (1)
    How To Setup Your Own Dns (Domain Name Server) This is only a quick tutorial, there are literally
    hundreds of little tricks you can do with a DNS, but this will get your basics up and running.
    I'm assuming you want to setup a windows DNS server, but the principals will work for most
    servers. You will need.. 1) A domain name over which you have full control 2) DNS server
    software(Windows server always comes with one of these) 3) At least one fixed IP address, allthough
    two is highly desirable 4) An idea of what services you want on your server The first thing you ....
  9. Parking Domains
    howto on adding a purchased domain to your account here (3)
    I wrote this tutorial for astahost, but I thought I'd add it here too /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> QUOTE Since this is something we may encounter
    while being hosted here I thought I'd touch the subject /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> First of all this tutorial/how to is written for
    those who have purchased a domain name through a registrar /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> Depending on how your registrar works, you should
    be able ....
  10. How To Create Virtual Drives
    A complete guide on how to create virtual drives (34)
    I'm planning to format my computer tonight, and I need some sort of reference about this when I
    get back. What is a virtual drive? A virtual drive is a shortcut to a folder hidden deep inside
    Windows. Instead of having an icon for the shortcut (virtual drive), you will see a drive icon with
    a letter that you chose when you go to My Computer after you create the drive. After completing this
    tutorial, you will be able to turn a long path
    (C:\directory\directory\more\directory\oh\my\gosh\this\is\a\long\directory\) into a drive letter
    (L:). Why should I have a virtu....
  11. Set-up Your Registered Domain Name
    at GoDaddy.com (14)
    Alright, here is how you set-up your registered domain name with Trap17. I bought
    http://www.zroenergy.net at http://www.godaddy.com so I know how it works first hand.
    /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> First go to
    http://www.godaddy.com Then go to My Account, and login. Then go to Manage Domains under the
    Domain section of the page you get after logging in. Now the domain you bought will be listed. If
    there is a lock next to it, click on your domain name. On the right of the next page under "Domain
    Details" click unlo....

    1. Looking for How, To, Assign, A, Virtual, Domain, Name, To, Your, Localhost.

Searching Video's for How, To, Assign, A, Virtual, Domain, Name, To, Your, Localhost.
See Also,
advertisement


How To Assign A Virtual Domain Name To Your Localhost. - Assigning virtual domain names and websites to your localhost.

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com