1

I am trying to point a URL to a particular IP address.But the IP belongs to the domain and I want it to point to a subdomain belonging to that domain.I am doing this by altering the hosts file in the etc directory.So is it possible for me to do that?

1

Not sure I understand the question but if you want something like subdomain.xyz.com to point to particular IP address of your choice then yes, the hosts file will do that.

3
  • Yes but is there any way by which I can have a functionality of pointing a URL to a URL instead of an IP address? Dec 18 '12 at 9:58
  • You cannot point a url to another url using a hosts file. Maybe we can help if we know exactly what you're doing.
    – user72593
    Dec 18 '12 at 10:12
  • Yeah I have a site hosted on my webhost account.I need to use a special IP on my workstation to access that site easily.But I am unable to do that.Is there an alternative solution to this? Dec 19 '12 at 6:14
0

Most likely: No.

The /etc/hosts file is like a local DNS-server. If your only concern is a local connection to the subdomain then it would work.

If you expect your visitors/users of your application to also see this subdomain entry, then it would not work as you expect.

You could then either visit everyone personally and alter their /etc/hosts file. While this sounds funny, it might be a quick solution if you want your co-workers see a certain subdomain correctly.

The other, more global solution would be an entry in your Nameserver. If you don't have access to those (I don't), then see if your provider has some webinterface to configure that or ask them.

EDIT: Please note that the /etc/hosts file is a simple mapping of domain-names to ip-addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.