Jump to content

Multiple domains. Single Application.


leon_nerd

Recommended Posts

Hello,

 

I have been working on an architecture for quite some time and one problem that I have not been able to find a suitable solution is being mentioned here.

 

I have multiple domains but they all have to run using a single application. For example www.123.com, www.456.com, www.abc.com, all of these applications are going to use a single set of application files. My problem is:

 

Whenever the user types in a domain name say www.123.com, it will be redirected to the central application. Now, this application is stored in an other folder. So, the URL will change. So, if I type in like www.123.com/home.php then it will access the home.php in the application folder and will change the URL to something like www.centralapplication.com/home.php. I want to keep the URL same. I don't want the URL to change. So, the user should be able to use the applicaiton as www.123.com/ rather than www.centralapplication.com/

 

Now, I have been researching on this issue. Someone suggested me to keep all the files in a folder and write APIs that I will place in each domain folder. So, whenever a user types in a site name the APIs stored in its folder will access the files from the application folder. I am not sure how this will work. Any idea?

 

Another approach suggested was to use $_SERVER['HTTP_HOST'] to determine which site it is, and get the request through $_SERVER['REQUEST_URI']. So if we make the request http://www.example.com/user/login then you'll have:

HTTP_HOST = www.example.com

REQUEST_URI = /user/login

 

I am not sure how this approach works.

 

So, can you please help me out in deciding the best solution for this problem. I really don't have much idea about this since I am doing it for first time.

 

Thanks a lot in advance.

Link to comment
https://forums.phpfreaks.com/topic/153333-multiple-domains-single-application/
Share on other sites

So would http://www.abc.com/home.php and http://www.centralapplication.com/home.php be the exact same page? If that's the case you just need to set them up as addon domains through your hosting provider.

 

If you're familiar M-V-C you might see something like this:

 

http://www.domain.com/controller/action

 

However you might want to have:

 

http://www.someotherdomain.com/action essentially "point to" http://www.domain.com/controller/action

 

Is this the same scenario you're talking about?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.