Tallboy
Tallboy

Reputation: 13467

change DNS with php like as if editing hosts file?

I don't know how to phrase this better, mainly because I dont really know how DNS fully works.

Given a URL and an IP, is it possible to tell PHP to make all requests to that IP AS the given URL instead of the real DNS (Just as if you edited your hosts file locally)?

Upvotes: 2

Views: 2365

Answers (3)

Saic Siquot
Saic Siquot

Reputation: 6513

I think this is what apache does via .htacess or other configuration files. That is not a "change" to the DNS, but a way to manage every request as you want, even with a unique and generic .php file

Upvotes: 0

Mike Brant
Mike Brant

Reputation: 71422

Unfortunately for your case, you are at the whims of your client.

If they type the IP address in their browser it will work, if they type the domain which has not been set up in DNS or in their hosts files, it will never reach a server that you control.

If you have designed you site correctly, it probably really shouldn't matter if they access it via domain name or IP address.

Upvotes: 0

JvdBerg
JvdBerg

Reputation: 21866

The only solution I see is to run your own bind server, and tell your clients to use your bind server. You then have full control how a name is routed to a IP.

Upvotes: 1

Related Questions