开发者

Set up host file using port

开发者 https://www.devze.com 2023-03-22 09:10 出处:网络
I want to setup my host file to 127.0.0.2:5050 domain2.com=> this is开发者_如何学编程 a local domain

I want to setup my host file to

127.0.0.2:5050 domain2.com => this is开发者_如何学编程 a local domain

when a type in my browser domain2.com, this return me : HTTP Error 404. The requested resource is not found.

i use this in apache

<VirtualHost 127.0.0.9:5050>

    ServerAdmin info@domain2.com
    DocumentRoot "C:/Users/My_Dir/LOOP/WebEnginer-2011/domain2_Dir/"
    ServerName domain2.com
    DirectoryIndex index.php index.html index.htm
    ServerAlias www.domain2.com
    ErrorLog "c:/wamp/xxxx/xxxx.log"
    CustomLog "c:/wamp/xxxx/xxxx.log" common
</VirtualHost>

<VirtualHost 127.0.0.9:5050>

    ServerAdmin info@domain2.com
    DocumentRoot "C:/Users/My_Dir/LOOP/WebEnginer-2011/domain2_Dir/admin_Dir/"
    ServerName admin.domain2.com
    DirectoryIndex index.php index.html index.htm
    ServerAlias www.admin.domain2.com
    ErrorLog "c:/wamp/xxxx/xxxx.log"
    CustomLog "c:/wamp/xxxx/xxxx.log" common
</VirtualHost>

but when i type 127.0.0.2:5050 i can see a web page. I want to use subdomain like admin.domain2.com

i can't use port 80 because IIS use that port.

How can i set up my host file to listen domain2.com?


That won't work since the hosts file only serves the purpose of mapping a hostname to an IP-address. The port number of a service is a different concept and is not handled by the "hosts" file nor the DNS-System. In Short: you can't supply a port number in the "hosts" file.

If your Webserver works on another port, you have to supply that information in the URL: http://domain2.com:5050.

The only other solution is to configure your Webservers to listen on a specific IP so that they don't interfere with each other. For example the IIS could listen on 127.0.0.1 and the Apache on 127.0.0.2 (the way you have already configured it).

There's a HOWTO for achieving that with the IIS. I'm not sure if that works for 127.0.0.x-IP's but I think it's worth a try.


It might be:

  • Your DNS resolver not resolving that properly
  • Some Apache webserver misconfiguration

Try this to get more information about that:

  1. What if you ping domain2.com?
  2. Also, try what happens if you put something like domain2.local in your hosts file. It might be some windows security c** disallowing you to overwrite the ip of an existing domain.
  3. Why didn't you use 127.0.0.1? That should be fine, however
  4. Make sure you have a properly configured VirtualHost that accepts requests to "domain2.com", or you just have a default virtualhost.

EDIT What did you actually add to hosts file? The correct syntax would be:

127.0.0.2     domain2.com
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号