Welcome Guest, Not a member yet? Register   Sign In
CI and Wildcard Domains
#1

[eluser]chadtomkiss[/eluser]
Hi,

We have a site that allows the user to set up their own website, and choose a custom domain.

I am currently trying to route all wildcard domains to a single controller to load their content etc.

However, using htaccess, I get a 500 error.

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

r->uri = /external
redirected from r->uri = /external
redirected from r->uri = /external

I then tried to copy index.php, call it external.php and edit the $routing array to specify the controller I want to be called.

This seems to work, but does not load CSS/images etc - going to their URL just loads the page being displayed.

Any help would be much appreciated.


Kind regards,

Chad
#2

[eluser]chadtomkiss[/eluser]
Not ideal, but this seems to work fine in routes.php:

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

// Routes for default domain

$route['default_controller'] = "home";

} else {

// Routes for all other domains

$route['default_controller'] = "external/home";

}
#3

[eluser]oppenheimer[/eluser]
perhaps you need to set the base_url as specified in this link:

http://codeigniter.com/wiki/Automatic_configbase_url/
#4

[eluser]chadtomkiss[/eluser]
I have already set the base_url() to be dynamic.

It just seems to route every request to that controller regardless of whether its css/image/js.

The way I have above works fine, it's pretty much the same as the htaccess rules!

However, doesn't explain why css etc isnt routing properly - would be good to figure out why when using $routing array in index.php (its commented out by default)


Cheers.
#5

[eluser]Stoney[/eluser]
Quote:I am currently trying to route all wildcard domains to a single controller to load their content etc.

Why don't you route all traffic to a single controller with routing from routes.php?

I'm doing it like this (multilang site):

Code:
$route['default_controller'] = "main";

//excluding controllers from routing to main
$route['^en/dashboard/(.+)$'] = 'dashboard/$1';

$route['^en/(.+)$'] = $route['default_controller'].'/index/$1';
$route['^en$'] = $route['default_controller'].'/index/$1';




Theme © iAndrew 2016 - Forum software by © MyBB