Chrome resolves DNS errors, which is rare, even a bit peculiar. There is a very strange phenomenon when you use Apache to configure a virtual host today. I followed the configured steps to configure the virtual host as follows
The steps to configure a virtual host are as follows :
1. Enable httpd-vhosts.conf
In the httpd.conf file
# Virtual hosts, web hosting
Include conf/extra/httpd-vhosts.conf
2. Configure in the httpd-vhosts.conf file
# Configure our own web hosting
<virtualhost 127.0.0.1:80>
DocumentRoot "D:/myblog"
# Welcome to the first page in this configuration
DirectoryIndex index.html index.htm index.php
<directory/>
Options FollowSymLinks
# Nobody can change our page
AllowOverride None
# Set access Permissions
Order Allow,deny
Allow from all
because of the version update, so this statement can no longer be used,Apache2.4 need to use Require all granted
</Directory>
</VirtualHost>
3. Modify The hosts file
.127.0.0.1 localhost
But unfortunately, I am debugging the browser is Chrome, which makes me just start to solve the problem when the wrong direction, I was just beginning to think of my configuration error, so I have been trying, but finally did not find the problem, Chrome browser stay on this page. (This page is the default page of Apache, not the page in the virtual host)
Later, I think it will not be the Hosts file error? So I tried to use IP:HTTP://127.0.0.1/access, and to my surprise, this time the visit was successful.
So I decided that the problem arose between localhost and ip:http://127.0.0.1/, to find the point where the problem occurred, and then I found the results in Baidu 1, localhost also called local, the correct explanation is: local server 127.0.0.1 in Windows and other systems the correct explanation is: the native address (native server) their resolution through the host file, Windows automatically resolves localhost to 127.0.0.1 2, localhot (local) is not transmitted through the network card! This is important, and it is not limited by network firewalls and Nic-related. The 127.0.0.1 is transmitted through the network card, relies on the network card, and is restricted by the net firewall and the NIC. The local IP is also transmitted through the network card, relying on the network card, and is subject to the Internet firewall and Nic-related restrictions. However, the difference between the native IP and 127.0.0.1 is: 127.0.0.1 can only be accessed through native IP through native access and also through external access to the general Setup program when the local service with localhost is the best, localhost will not be resolved to IP, and will not occupy the network card, network resources. (Source: http://www.linuxde.net/2011/11/2915.html) But I can't solve this problem even if I find these differences, because my configuration is correct on the Internet. Well, I think the most critical issue is the version of Apache, but it didn't happen after the search. This time only the last possible, that is the browser has a problem, so I used the Sogou browser to access. The results are normal and we finally know where the problem is. There is a problem with the Chrome browser.
After identifying the source of the problem, I found the answer again in Baidu, but I couldn't find the answer. I think the main reason may be because less people use, and is not the mainstream, so the problem is relatively small. So had to fq out, to Google to find the answer. Thank almighty Google, finally found the answer to the question on the http://stackoverflow.com: http://stackoverflow.com/questions/30477552/ Google-chrome-virtual-hosts-not-working-with-err-name-not-resolved-error-after-u the key to the original problem is the DNS parsing, but I'm really stupid, DNS is the browser parsing ah, it must be a browser problem. Let me tell you how to solve the problem:
Down voteaccepted |
Method One: 1Clear up the Chrome's DNS cache by typing this in the Chrome browser
- chrome://net-internals/#dns
Screenshot-Flushing Chrome DNS Cache
You'll see a button "Clear Host Cache". Press that DNS cache would be flushed.
Keep this DNS window open. Now access the virtual host in the browser for me it is http:/api.localhost. Once you do, you'll see a new entry in the DNS window. For me it is "localhost." Notice the period "." At the end of the localhost that showed an error.
Last step was to simply add this entry as 127.0.0.1 localhost. In the Hosts file located on for Ubuntu: /etc/hosts For Windows: C:\Windows\System32\drivers\etc\hosts
Method Two: Another solution could is to ditch the. LocalHost/.dev at the end of the your local virtual host domain This have to does with some new changes by Google. ". Dev" and ". Local" comes under Google's TLD (in the corner of the internet where people care for DNS, there is a bit of An uproar at Google's application for over a hundred new top-level domains, including. Dev etc) Use a domain name own. The possibly using the full name is "Localhost.dev. $yourdomain" could help here on the setup. |
Originally, after the Google browser upgrade, the DNS parsing has produced new rules, such as. Localhost/.dev are one of the Google's TLDs, so you can no longer use Google Chrome to access the local via localhost. However, the above method I found after the test is still not possible, guess the reason is that with the higher version of the upgrade, the resolution of the DNS more stringent. Therefore, it is recommended to use method Two, that is, to change the localhost to Localhost.dev. $yourdomain "or whatever (as long as the". LocalHost "does not appear). Of course, this needs to be in Windows:
configuration in C:\Windows\System32\drivers\etc\hosts. So here, the problem is solved perfectly. Here again to remind yourself, encounter problems do not panic, in-depth analysis of the problem, analysis of the problem belongs to what kind of problem, the use of easy-to-search words to describe the error, search engine searching for the corresponding solution, if still can not solve, to Google up search, if still can't solve, can go to the forum to ask, so, Generally there is no problem that cannot be solved. Stack overflow is really a good place and I have a lot of questions here to find out how to fix it.
After Apache has configured the virtual host, use Chrome to access localhost or the default directory Htdocs