Welcome Guest, Not a member yet? Register   Sign In
subdomain and caching
#1

[eluser]BeingDefined[/eluser]
Here's the deal. I have subdomain1.site.com and subdomain2.site.com. Each have their own controller which I have defined in routes in this format:

Quote:switch ($_SERVER['HTTP_HOST']) {

case 'subdomain1.site.com':

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

break;

case 'subdomain2.site.com':

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

break;

}

Everything works until I enable caching. Whichever gets cached first also seemed to be cached for the other. So if subdomain1.site.com gets cached first, I see the same page on subdomain2.site.com even though they are completely different content. I think the problem is with the path. Since the path for both of the subdomain is "/", its using the hash for "/" and just outputting which matches it. I did do a search on the forums and I found someone with a similar problem here: http://ellislab.com/forums/viewthread/95540/ but no one responded to his question so I hope its not the same here ;-P

Thanks all!
#2

[eluser]narkaT[/eluser]
try to change you base_url in your config.php according to the subdomain.

if both subdomains use the same base_url, the md5-hashes of the home-pages will be the same Smile
#3

[eluser]sikkle[/eluser]
maybe just :

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'].'/';

good luck.
#4

[eluser]narkaT[/eluser]
I would rather hardcore that, like in the initial post.
Otherwise an attacker could modify the host-header and inject a malicious url Wink

An alternative would be $_SERVER['SERVER_NAME'] but according to the manual the
subdomain has to be declared as an virtual host for that to work.
#5

[eluser]sikkle[/eluser]
yep yep, i mean depend if he is already on production env actually.

but you totally right.
#6

[eluser]BeingDefined[/eluser]
They're actually different domains, not subdomain. I just said subdomain to make it little simpler.

And so yes $_SERVER[‘SERVER_NAME’] trick did the job Smile Thanks guys!




Theme © iAndrew 2016 - Forum software by © MyBB