[英]How to make my local website opens by URL
I setup an apache server and created a website in: var\\www\\mywebsite
. 我安装了一个Apache服务器,并在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. 但是,当我在地址栏中键入完整目录路径时,将显示网站index
页面。 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? 在地址栏中输入网站名称test.com
时,如何直接打开网站主页?
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. 当您在Web浏览器中键入test.com时,操作系统正在执行DNS查找,并尝试将test.com解析为IP地址。 Since test.com is a valid website, it's directing you there. 由于test.com是有效的网站,因此可以将您定向到那里。
If you want to view your website, you'll need to type http://localhost into your web browser. 如果要查看网站,则需要在Web浏览器中键入http:// localhost 。 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. 或将127.0.0.1 test.com
添加到您的/ etc / hosts文件中,这将强制操作系统将对test.com的请求解析为本地主机IP地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.