Welcome Guest, Not a member yet? Register   Sign In
[Solved]: Gonna loose my job today !!! default controller redirecting url http://domain.com to http://www.domain.com. Wh
#28

[eluser]Sarfaraz Momin[/eluser]
Hi,
Thanks all of you guys for your prompt replies and your assistance that I have got the issue resolved. What I did was basically follow Derek's suggestion to not use _remap function instead what I did is I made some conditional routes which works fine and allows me to make the wildcard subdomains work for various categories as well. My route.php is as follows for someone who might be in as tight situation as I was in.

route.php
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/";    
}

This helped me to remove the _remap function from my front controller. Apart from this I had to move the code for subdomain handling in a seperate controller named subdomaincat which is further good as it will help me to manage the code easily.

Thanks again to all of you and if you feel that the above code can be optimized further please feel free to comment. I would keep a track of this post from time to time for any enhancements.

Regards and 3 Cheers to the victorious !!!!

WE LOVE CI and IT's GREAT TEAM.


Messages In This Thread
[Solved]: Gonna loose my job today !!! default controller redirecting url http://domain.com to http://www.domain.com. Wh - by El Forum - 10-03-2007, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB