简体   繁体   中英

How to make my local website opens by URL

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM