One App That Responds to Multiple Domains

dchuk

Senior Botter
Oct 30, 2008
7,044
224
0
San Diego,CA
serpiq.com
Alright, so I'm programming a webapp (Codeigniter based) that will use the NameCheap API to buy domains and point them at my server. On my dev machine, I've set it up with multiple local hosts and it works perfectly. The app checks the domain each time a request is made and loads the content relevant to the domain being called.

My question is, do I also need to park the domain through my hosting control panel to get the same effect online? Or will it just work if I set the nameservers correctly at NameCheap?

On a side note, I think I might go with MediaTemple to host the app so it has Plesk and I might be able to use their API to do domain aliasing. Anyone have experience with that?
 


You'll just need the domain pointed to the IP of your server, and your Apache configured with a wildcard namevhost to accept the traffic from whatever domain to your app.
 
Pardon the newbiness of this, but can you give me a short rundown why it's a huge security risk?

And instead of doing a wildcard domain, would a safer route be using the CPanel API to programmatically park the domains? Does that keep things safer/follow the safe list method?
 
I'm curious as well as to why this might be a security risk, especially if his app is checking the domain.

Seems about the same as how a ton of other sites out there are hosted already as it is.
 
So Eli, clearly you have a hold on this subject pretty well. Here's my plan, I'm tripping up on whether it will work correctly, so if you could help me out that would be tits.

I'm going to use the Namecheap API to programmatically purchase domains in my app and set them up with my host's name servers. Once that is done, what do I need to do server side to make my app respond to the domain that now points at my server? Anything?

Originally I planned on tapping into the CPanel API and just parking each new domain as an extra step after buying and pointing them. Is that my best bet to prevent against any potential security risks? Do you know if there are limits or reasons to why I wouldn't park a shit load of domains on a single account?
 
So Eli, clearly you have a hold on this subject pretty well. Here's my plan, I'm tripping up on whether it will work correctly, so if you could help me out that would be tits.

I'm going to use the Namecheap API to programmatically purchase domains in my app and set them up with my host's name servers. Once that is done, what do I need to do server side to make my app respond to the domain that now points at my server? Anything?

Originally I planned on tapping into the CPanel API and just parking each new domain as an extra step after buying and pointing them. Is that my best bet to prevent against any potential security risks? Do you know if there are limits or reasons to why I wouldn't park a shit load of domains on a single account?
Yeah if separate ips aren't a concern then addon domains would be the way to go. An addon domain adder (haha try to say that 3 times fast) already exists so that portion is easy.
http://www.zubrag.com/downloads/cpanel-addon-domain.zip

I assumed from yoru first post you already figured out how to get the app to respond to the domain its just using the environmental variable HTTP_HOST. If you read the first link i gave ya. it gives an example of how to set that up. The second has an example code for using the HTTP_HOST to select the db (although table or value in a table works the same way).

If you need any additional help feel free to pm me.
 
Yeah if separate ips aren't a concern then addon domains would be the way to go. An addon domain adder (haha try to say that 3 times fast) already exists so that portion is easy.
http://www.zubrag.com/downloads/cpanel-addon-domain.zip

I assumed from yoru first post you already figured out how to get the app to respond to the domain its just using the environmental variable HTTP_HOST. If you read the first link i gave ya. it gives an example of how to set that up. The second has an example code for using the HTTP_HOST to select the db (although table or value in a table works the same way).

If you need any additional help feel free to pm me.

Yeah I already have that portion down, but thanks for all of the help and links. I'll let you know the results of the addon domains