is it possible to  create subdomains on my localhost? like sub.localhost
and would like to know how subdomains work.
            Asked
            
        
        
            Active
            
        
            Viewed 4.1k times
        
    36
            
            
         
    
    
        Mehman Manafov
        
- 449
- 1
- 4
- 8
- 
                    Check out the [HostAdmin](https://www.google.com/search?q=HostAdmin) extension. – Amal Murali Sep 13 '13 at 19:34
3 Answers
43
            Create a virtual host as such:
<VirtualHost *:80>
    ServerName sub.localhost
    DocumentRoot "C:/public_html/sub"
</VirtualHost>
And in your hosts file add this line:
127.0.0.0       sub.localhost
Here is a useful tutorial you might find helpful.
 
    
    
        SeanWM
        
- 16,789
- 7
- 51
- 83
- 
                    *.localhost should resolve out of the box, without adding anything to /etc/hosts :) Although in Debian I have this exact problem – holms Sep 03 '18 at 15:05
11
            
            
        You can make your browser to point to any domain/subdomain that you want as long as you put the ip - hostname definition in your c:\Windows\System32\drivers\etc\hosts file, for example:
127.0.0.1 localhost
127.0.0.1 sub.localhost
or on the same line separate by space:
127.0.0.1 sub.localhost subsub.localhost local.host
7
            
            
        Add the following to your local hosts file. On windows, it's located at C:\WINDOWS\system32\drivers\etc\hosts.
127.0.0.1       sub.localhost
Replace 127.0.0.1 with whatever IP address you want.
 
    
    
        Athens Holloway
        
- 2,183
- 3
- 17
- 26
 
    