当前位置: 动力学知识库 > 问答 > 编程问答 >

redirect - Send Sub-Domain to Different IP Using PHP - Not DNS

问题描述:

I have not been able to find a definitive answer for this, so I figured I would ask here. Is there any way of using PHP to essentially resolve to an IP based on sub-domain? I would use PHP header(), but the issue is that the IPs will not all be going towards web-servers. To better explain, I will give an example:

Client goes to s1.server.com and should be directed to 10.10.10.10

Client goes to s2.server.com and should be directed to 11.11.11.11

If possible, I would also like to be able to specify port, so something such as:

Client goes to s3.server.com and should be directed to 12.12.12.12:8080

I understand you can do all of this with the web engine (Apache, Nginx, etc) or by adding in multiple DNS entries for the subdomains. My problem is that I need a system that is very dynamic (DNS and engine entries need to be added in manually) and in the end I want something that will end up using a PHP script to look up IPs in a MySQL database based on what sub-domain is used.

Is anything like this possible? If yes, how would I go about doing so? If not, am I stuck using DNS or specific engine configurations in order to accomplish this?

分享给朋友:
您可能感兴趣的文章:
随机阅读: