Question

I am a beginner to Apache and have been trying to create virtual hosts but I come across a very odd issue. When the site is requested using the IP defined in the configuration, the virtual host works perfectly but when the name of the server is used it does not work. Here is the configuration file which is an included file:

Listen 80

NameVirtualHost 192.168.1.5

<VirtualHost 192.168.1.5>
ServerName host1.localhost
DocumentRoot "C:/Program Files (x86)/Apache Group/Apache2/virtualHost1"
</VirtualHost>

In the browser I go to 192.168.1.5 and the index file for the Virtual Host appears but when I go to host1.localhost it doesn't work.

Any help is very appreciated, good day to all.

Was it helpful?

Solution

First you should try to see if your computer resolve host1.localhost hostname.

May be just try to ping it in your console: ping host1.localhost

If your computer is unable to resolve host1.localhost, as I suppose, then try to add it in your hosts file.

Hint: you'll find hosts file in C:\Windows\System32\drivers\etc directory

OTHER TIPS

What do you mean by "it doesn't work".
1)Check your DNS settings, do you have record for host1.localhost pointing to 192.168.1.5?
2)Try using ServerAlias also
3)Check if there is another declaration for hosts1.localhost (by another ServerAlias)
I guess the most likely reason is 1)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top