possible to resolve DNS based on URL path

2019-02-11 04:32发布

问题:

My understanding is that there are certain advantages to putting two related sites under the same domain, as opposed to separate subdomains (for example sub-sites for different book genres). Two I can think of are using the same SSL cert, and SEO rankings.

I'd like to have different paths for the same domain resolve to different IP addresses. For example example.com/a to 100.100.100.100 and example.com/b to 200.200.200.200. I know this isn't possible with traditional DNS servers, but are there other techniques or commercial services out there that would accomplish this? Ideally I'd be also able to dynamically change where the paths resolve to as well, as different servers come on or offline.

回答1:

That can't be done; DNS' name to IP resolution only considers the hostname.

You could achieve a similar result by hosting a reverse proxy like nginx atexample.com, and then direct queries for /a to 100.100.100.100 and for /b to 200.200.200.200.



回答2:

You can't do it with DNS (DNS resolves only domain names to IPs, and have nothing to do with whatever comes after "/"), but you can do it with URL forwarding. Often DNS (especially dynamic DNS) providers also offer URL forwarding service, try companies like no-ip.com and such.



回答3:

You can do this with prefixes. A.example.com --> 100.100.100.100 and B.example.com -->200.200.200.200