CodeIgniter Forums
Codeigniter subdomains - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Codeigniter subdomains (/showthread.php?tid=43475)



Codeigniter subdomains - El Forum - 07-12-2011

[eluser]Citizen[/eluser]
Lets say I have my controllers organized as such:

/news/main.php
/news/recent.php
/business/main.php
/business/recent.php

How can I get news.domain.com to load the main.php controller from my /news/ controller directory?
And then news.domain.com/recent would load /news/recent.php controller


Codeigniter subdomains - El Forum - 07-12-2011

[eluser]ranjudsokomora[/eluser]
Hello Citizen,
You would need to modify the router class.
I'll see if I can write an example of what you are looking for. I'll post it here in a couple of hours.


Codeigniter subdomains - El Forum - 07-14-2011

[eluser]Citizen[/eluser]
[quote author="ranjudsokomora" date="1310527443"]Hello Citizen,
You would need to modify the router class.
I'll see if I can write an example of what you are looking for. I'll post it here in a couple of hours.[/quote]
Thanks, any help would be appreciated.


Codeigniter subdomains - El Forum - 07-16-2011

[eluser]Aken[/eluser]
Redacted. See below.


Codeigniter subdomains - El Forum - 07-17-2011

[eluser]Citizen[/eluser]
[quote author="Aken" date="1310824675"]Don't even need to mess with routes - a correctly-configured .htaccess file would do the trick.[/quote]

How would I do that without having to have a rule for every page within the subdirectory?


Codeigniter subdomains - El Forum - 07-17-2011

[eluser]Aken[/eluser]
My mistake - this would be better suited with DNS. See: http://stackoverflow.com/questions/586129/create-subdomains-on-the-fly-with-htaccess-php


Codeigniter subdomains - El Forum - 07-18-2011

[eluser]Citizen[/eluser]
Thanks, guys, but I'm still not sure what to do.

If it helps: I have a finite list of subdirectories that I want to use, only about 5 or so. I'm not looking to create a wildcard subdomain catcher.

And I'm aware of how to create subdirectories through DNS or with htaccess, but I'm not sure what the best practice would be for codeigniter. I'm hoping someone can tell me what the best way to do this with codeigniter.