0

I have been struggling with managing domains for two separate EE installations. Htaccess redirects only seem to work with the site's homepage. Anything beyond that results in a 404 error.

For example: http://domain.com is set as the root, and uses index.php to set the systempath variable thusly: $system_path = ‘./site1/‘;

My 301 redirect was pointing http://domain2.com to http://domain2.com/site2, which is what is causing the template mapping to fail. So, http://domain2.com/template_group/ results in a 404 error.

What I want to do is point both domains toward the root, and have the index.php file detect the URL and do this:

if url is domain1.com { $system_path = ‘./site1/‘; } if elseif url is domain2.com { $system_path = ‘./site2/‘; }

I’m not sure what the proper syntax to use is, though. I know that CodeIgnitor has some specific functions for handling URLs.

Conversely, if someone can help me figure out why the htaccess isn't functioning. Either way, I just need to resolve the issue.

Thanks,

ty

3
  • I tried this: $host = $_SERVER['REQUEST_URI']; if($host == 'domain1.com') { $system_path = './site1/'; } else { $system_path = './site2/system/'; } But the domain1 isn't being detected properly.
    – Ty Morton
    Nov 29, 2014 at 18:58
  • I dont get it. Both sites operate independently yeah? Why use redirect to site 2 Dec 1, 2014 at 4:59
  • Because, internally, EE couldn't navigate the directory structure. Instead of domain2.com/template_group, it was looking for domain2.com/site2/template_group.
    – Ty Morton
    Dec 1, 2014 at 17:12

1 Answer 1

0

This seems to do the job nicely:

$host = $_SERVER['SERVER_NAME'];
if($host == 'domain1.com') 
{
    $system_path = './system/';

}
else
{
    $system_path = './site2/system/';

}   
2
  • So its not 2 separate EE installs? Its one install serving 2 domains? Dec 2, 2014 at 0:43
  • No, it is two separate installs.
    – Ty Morton
    Dec 2, 2014 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.