CodeIgniter Forums
codeigniter and subdomains - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: codeigniter and subdomains (/showthread.php?tid=11149)



codeigniter and subdomains - El Forum - 08-28-2008

[eluser]emperius[/eluser]
I have web-site which should be spread to sub-domains

sub1.site.com
sub2.site.com

is that possible to do something like this whitout mod_rewrite in codeigniter?


codeigniter and subdomains - El Forum - 08-28-2008

[eluser]drewbee[/eluser]
I assume your talking about virtual domains? IE user1.domain.com user2.domain.com

Yes, you will defininitely need htaccess if that is the case.

Though it could simply be taken care of by routing rules.


codeigniter and subdomains - El Forum - 08-29-2008

[eluser]Thorpe Obazee[/eluser]
[quote author="emperius" date="1219926375"]I have web-site which should be spread to sub-domains

sub1.site.com
sub2.site.com

is that possible to do something like this whitout mod_rewrite in codeigniter?[/quote]

I am sorry but I don't think I understand. From what I know, I don't think subdomains would affect installations of codeigniter. Unless of course I don't really understand :p


codeigniter and subdomains - El Forum - 08-29-2008

[eluser]Sarfaraz Momin[/eluser]
You can surely achieve it by making a small modification in you server DNS settings. You just have to add a new cname record with the following data *.site.com which would redirect all subdomains to you main domain and then you can edit the route file to achieve whatever you want. I can give u an example of what I did with it.
Code:
switch ($_SERVER['HTTP_HOST']) {
    case 'category1.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category2.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category3.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category4.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category5.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category6.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category7.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category8.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category9.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category10.domain.com': $route['default_controller'] = "subdomaincat"; break;
    case 'category11.domain.com': $route['default_controller'] = "subdomaincat"; break;
    default: $route['default_controller'] = "front"; break;
}

$route['scaffolding_trigger'] = "";

if($_SERVER['HTTP_HOST'] == "www.domain.com" || $_SERVER['HTTP_HOST'] == "domain.com")
{

// Routes for domain.com
$route['homesort/([^/]+)/([^/]+)'] = "homesort/index/$1/$2";

$route['search/([^/]+)'] = "front/search/$1";

$route['sort/([^/]+)'] = "front/subdomaincategory/sort/$1/";
$route['([0-9]+)'] = "front/subdomaincategory/page/$1/";

$route['([^/]+)/([^/]+)\.html'] = "front/content/$2/";

$route['([^/]+)/([0-9]+)'] = "front/category/$1/page/$2/";
$route['([^/]+)'] = "front/category/$1/";
$route['([^/]+)/([^/]+)/([0-9]+)'] = "front/category/$1/$2/page/$3/";
$route['([^/]+)/([^/]+)'] = "front/category/$1/$2/";
$route['([^/]+)/sort/([^/]+)'] = "front/category/$1/sort/$2/";
}
else
{    
// Routes for sub.domain.com
$route['sort/([^/]+)'] = "subdomaincat/subdomaincategory/sort/$1/";
$route['([0-9]+)'] = "subdomaincat/subdomaincategory/page/$1/";
$route['sort/([^/]+)'] = "subdomaincat/subdomaincategory/sort/$1/";
$route['([0-9]+)'] = "subdomaincat/subdomaincategory/page/$1/";
$route['([^/]+)/([0-9]+)'] = "subdomaincat/category/$1/page/$2/";
$route['([^/]+)'] = "subdomaincat/category/$1/";
$route['([^/]+)/([^/]+)/([0-9]+)'] = "subdomaincat/category/$1/$2/page/$3/";
$route['([^/]+)/([^/]+)'] = "subdomaincat/category/$1/$2/";
$route['([^/]+)/sort/([^/]+)'] = "subdomaincat/category/$1/sort/$2/";    
}



codeigniter and subdomains - El Forum - 08-29-2008

[eluser]daulex[/eluser]
Sarfaraz, you rock dude! + rep if there was such a thing Big Grin


codeigniter and subdomains - El Forum - 09-08-2008

[eluser]abhigudi[/eluser]
hi guys,
i have similar subdomain problem ...
i have my site configured in my server

http://test.com/cityname

where cityname contains the actual content ...

this works fine when i execute
cityname.test.com

but when i say cityname1.test.com
i have problem in linking cityname.test.com ....

what should i do,
i have researched in forum but i have not got the solution yet ...

how can i do that ...


codeigniter and subdomains - El Forum - 03-31-2014

[eluser]Unknown[/eluser]
Not working when use cache.