It depends what you mean by "subdomain" and what you mean by "accessible only by IP address".
If, say, you're trying to access google.com and maps.google.com, but for some reason your local DNS server doesn't have an entry for google.com, then you may as well query it for maps.google.com as they're separate entries (usually).
If you don't have a domain name for the website but instead only an IP address, then what does a "subdomain" of that mean? Say you're browsing to http://87.87.87.87, what is a "subdomain" of that?
Finally, it is usually pointless trying to reach a subdomain by connecting to the same IP address, as subdomain matching at the webserver-level is done by looking at the headers sent by the client, which wouldn't contain any subdomain information if you're connecting by IP address.
You have to add this IP address to your webserver as well if you are putting data into a particular directory and sharing the webserver with another website. If not, then you are just going to get the primary website and the subdomain will not do any good.
Add subdomain.website.com to your /etc/hosts file, pointing to that IP.
It depends what you mean by "subdomain" and what you mean by "accessible only by IP address".
If, say, you're trying to access
google.com
andmaps.google.com
, but for some reason your local DNS server doesn't have an entry forgoogle.com
, then you may as well query it formaps.google.com
as they're separate entries (usually).If you don't have a domain name for the website but instead only an IP address, then what does a "subdomain" of that mean? Say you're browsing to
http://87.87.87.87
, what is a "subdomain" of that?Finally, it is usually pointless trying to reach a subdomain by connecting to the same IP address, as subdomain matching at the webserver-level is done by looking at the headers sent by the client, which wouldn't contain any subdomain information if you're connecting by IP address.
You have to add this IP address to your webserver as well if you are putting data into a particular directory and sharing the webserver with another website. If not, then you are just going to get the primary website and the subdomain will not do any good.