CodeIgniter Forums
CodeIgniter app to manage hundreds of domains - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: CodeIgniter app to manage hundreds of domains (/thread-34233.html)



CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]transition[/eluser]
We developed some custom app here with CodeIgniter to help manage all of the domains we own (180+). Most of these domains will have simple 1 page content. The goal I have is to be able to create a single front-end controller on our master domain (lets say it's at /home/master/www). Lets say one of the sites i'm managing is called TestSite.com. This site is located at /home/testsite/www on the same server as the master site. What i'd like to be able to do is whenever someones goes to TestSite.com is to make that request on our master site so we can lookup the associated template for that site and deliver the requested content. I don't want a redirect - it needs to look as though you're browsing TestSite.com even though requests are being pushed to the Master site.

Does anyone have an idea of how I can take requests on the TestSite.com and redirect them locally to the Master without the user knowing? Or is there an easier way to do this that i'm not thinking of?

edit: i'm desperate for a solution here. $20 paypal'd to whoever can propose a workable solution :-)


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]WanWizard[/eluser]
Use $_SERVER["HTTP_HOST"] to check which domain was requested, link it to a view using some logic, and display the view.


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]transition[/eluser]
Hi Wan - that part we've figured out. I'm trying to figure out how I can forward this traffic from sites like TestSite.com to the master site so i don't have to install this app on 180+ individual websites.


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]Rodrigo Ferreira[/eluser]
You may try something with mod_rewrite. You'd have to insert a .htaccess file in all domains with something like...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule (.*) http://mastersite/$1
</IfModule>

... or setup a default rewrite rule in http.conf.

You could also rewrite the system path. For more information:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]transition[/eluser]
[quote author="Rodrigo Ferreira" date="1285283158"]You may try something with mod_rewrite. You'd have to insert a .htaccess file in all domains with something like...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule (.*) http://mastersite/$1
</IfModule>

... or setup a default rewrite rule in http.conf.

You could also rewrite the system path. For more information:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html[/quote]

Tried the first directive although it just seems to redirect me not rewrite. What i need might be in the that link but i can't figure it out.


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]Rodrigo Ferreira[/eluser]
If the domains are in different hosts you may use the proxy option (put the '[P]' in the end of the line):
^/somepath(.*) http://otherhost/otherpath$1 [P]

Take a closer look in the RewriteRule directive.


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]transition[/eluser]
[quote author="Rodrigo Ferreira" date="1285284080"]If the domains are in different hosts you may use the proxy option (put the '[P]' in the end of the line):
^/somepath(.*) http://otherhost/otherpath$1 [P]

Take a closer look in the RewriteRule directive.[/quote]

Perfect! Check your PM's - thanks!


CodeIgniter app to manage hundreds of domains - El Forum - 09-23-2010

[eluser]Rodrigo Ferreira[/eluser]
I'm a new registered user and the system didn't allow me to reply the PM (new users have to wait one hour).

Regarding paypal, I've received a lot of good information here for free, so there's no need to pay me. I'm glad I was able to help you! Just help someone else when you have the chance and we'll be even! Smile


CodeIgniter app to manage hundreds of domains - El Forum - 09-24-2010

[eluser]WanWizard[/eluser]
Nothing complicated is needed.

If you have a dedicated IP for all these domains, you don't have to do anything other then to create a DNS entry for the domain pointing to the IP of your server. If you run more on the servers IP, you already have virtual hosts setup. In that case, just add extra 'ServerAlias' entries to the vhost, to direct requests for those domains to your site. Add as many as you want.