Reputation: 1155
I setup an apache server and created a website in: var\www\mywebsite
.
When I type my website name in the browser's address bar, it directs me to the internet. When I disabled the network (as temporal solution) it did not open the website at all. However, the website index
page shows when I type the full directory path in the address bar. I did virtual host by:
$ cd /etc/apache2/sites-available/
$ sudo nano test.com.conf
Then, type:
<VirtualHost *:80>
ServerAdmin carla@localhost
DocumentRoot /var/www/test.com
ServerName test.com
ServerAlias www.test.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
How can I make my website home page opens directly when I write my website name test.com
in the address bar?
Upvotes: 1
Views: 4329
Reputation: 642
When you type test.com into your web browser, the operating system is doing a DNS lookup and trying to resolve test.com into an IP address. Since test.com is a valid website, it's directing you there.
If you want to view your website, you'll need to type http://localhost into your web browser. Or add 127.0.0.1 test.com
to your /etc/hosts file, which will force the operating system to resolve requests for test.com to the localhost IP address.
Upvotes: 2