Sub domains on localhost
When working with apache locally, the common way to use it is though the "http://localhost" url. When doing web development or some kind of testing, you might need to create sub domains on localhost, just like on online servers.
This post shows you how to create sub domains inside Apache on localhost. Its easy and takes only a few minutes.
1. Create sub domain hosts
First edit the /etc/hosts file to add the subdomains you wish to create.
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 enlightened
127.0.0.1 a.localhost
127.0.0.1 b.localhost
127.0.0.1 c.localhost
In the above example I have added 3 sub domains, namely a.localhost b.localhost and c.localhost
Now test the sub domains by pinging them, to make sure they are accessible
$ ping a.localhost
PING a.localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_req=3 ttl=64 time=0.028 ms
^C
As we can see above, the sub-domains are responding to our ping queries, only after we have added them to the hosts file.
2. Create your sub-domain document...
Read full post here
How to Create sub domains on localhost in apache on Ubuntu
When working with apache locally, the common way to use it is though the "http://localhost" url. When doing web development or some kind of testing, you might need to create sub domains on localhost, just like on online servers.
This post shows you how to create sub domains inside Apache on localhost. Its easy and takes only a few minutes.
1. Create sub domain hosts
First edit the /etc/hosts file to add the subdomains you wish to create.
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 enlightened
127.0.0.1 a.localhost
127.0.0.1 b.localhost
127.0.0.1 c.localhost
In the above example I have added 3 sub domains, namely a.localhost b.localhost and c.localhost
Now test the sub domains by pinging them, to make sure they are accessible
$ ping a.localhost
PING a.localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_req=3 ttl=64 time=0.028 ms
^C
As we can see above, the sub-domains are responding to our ping queries, only after we have added them to the hosts file.
2. Create your sub-domain document...
Read full post here
How to Create sub domains on localhost in apache on Ubuntu