ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Site Error: Unable to Load Site Preferences; No Preferences Found

November 11, 2011 5:13am

Subscribe [4]
  • #1 / Nov 11, 2011 5:13am

    davey

    27 posts

    Hi -

    Can’t believe this problem now… I searched long and hard for an answer… no luck.

    So, I am using EE2 and MSM, and this site url works:

    http://mydomain.com/index.php

    and ends up appropriately at: http://mydomain.com/index.php#/home

    BUT I am getting this error:

    Site Error: Unable to Load Site Preferences; No Preferences Found

    for the same site at:

    http://www.mydomain.com/index.php or http://www.mydomain.com

    http://www.mydomain.com is working in terms of it can access other directory resources and seems to access index.php somewhat before erroring out…


    What is going on? Where is this breaking? Is something just out of sync in EE db?

    Where in the index.php or in system settings in EE do you address this?

    Why does the WWW. vs. not having it get impacted by EE?


    thanks in advance,

    David

  • #2 / Nov 11, 2011 5:00pm

    Kevin Smith

    4784 posts

    Hi David,

    Sorry to see this issue come up for you. In order to best help you, let me find out a bit more about your setup. Do you have an .htaccess file in your web root? If so, could you paste its contents here in the forum?

    Going further back up the stack a bit, do you know if your system is set up to direct requests for http://www.mydomain.com to one web root and mydomain.com to another web root?

    What are the settings you have in place for the index.php file that sits in your web root?

    This is one way around the issue: Have you considered configuring your web server to only use either mydomain.com or http://www.mydomain.com? That is to say, redirect all requests for one of them to the other, and make that one the master domain? This is pretty typical on the web today, and it gives your site a certain amount of uniformity. For you, it would solve this problem.

  • #3 / Nov 15, 2011 2:21pm

    davey

    27 posts

    Hi Kevin,

    Thanks for your help and looking into this… I was away for a few days and now back at this.

    I can change a dns record to have like you said my www. refer to the domain without the www. or vice versa if the problem was the inverse - no doubt.

    I guess I want to know why its not working, so I can better understand what EE is doing in the stack as you kinda eluded to us figuring out.

    My basic instance before I added MSM into the mix, works fine with both www. or not using the www. to get at the output for my initial EE instance/site, here is a little test proving that:

    http://provok.me/ee/index.php/news

    or

    http://www.provok.me/ee/index.php/news

    I actually don’t see any htaccess files in any of my directories for EE or for virtual domains that are then setup via EE tutorial on setting up domains to point at same EE instance… HMMM. I wonder…

    Trying to explain setup further…

    My 2nd site is dev instance (MSM site) that has subdirectories setup, so I work on my client sites (3rd MSM site etc. and on) and present to clients here: clients.mywebdevconame.com/clientname which works, or if I went to http://www.mywebdevconame.com/clientname that will work as well…

    So for the production client site, my 3rd site aka using MSM for an addon site… that has its own domain, this is where my www. and not having www. is getting stopped within EE as the index.php is by the error of this post title is getting picked up - so there isn’t an issue with my dns or my webserver, other than maybe how subdirectories throws a wrench into my index.php or something else in EE? I don’t know…

    My client site index.php variables looks like this:

    $system_path = '/var/www/vhosts/myinitialinstancedomain.me/httpdocs/ee/bobcat';

    This works for all sites except my 3rd site in MSM and specifically we are just talking about the www. as the non www. routes fine to system

    $assign_to_config['site_name'] = 'client_name_msminstance_live';
    //$assign_to_config['cp_url'] = '';
    $assign_to_config['site_url'] = 'http://clientsiteurl.com';

    is this helping at all explain things?

    😊

    thanks, really want to get to know what it up or what I did to my instance to break this particular MSM site and its www. access

    thanks,

    David

     

  • #4 / Nov 15, 2011 2:25pm

    davey

    27 posts

    ps - where does this Site Error get triggered from? in what module? Seems like in 1.x version it all had to do with paths etc.

    Thing is again, the error is coming up, so we are fine in most of the stack, so I can’t see any htaccess issues or things like basepath being issues, we are beyond all that, no? My server is leaving htaccess pretty much wide open to some degree to rule it out for the moment… Again, I can get to the www. of this client MSM site but it goes to that error, and the non www. works fine… pointing back to my EE instance and the appropriate MSM entry as specified in the index.php as it was told to do…

    Baffled…

    thanks,

    David

  • #5 / Nov 15, 2011 2:33pm

    davey

    27 posts

    Small discovery…

    Maybe all my www. ‘s for my MSM sites going to EE would break if it not for the CNAME entries I have for those other domains?

    I did not for this site I am having issues with have a CNAME for the www. pointing at the domain name without the www.

    But, how then with MSM can it ever go to both www. and without www. to same domain as in index.php it only indicates one domain to go to:

    $assign_to_config[‘site_url’] = ‘http://clientdomainname.com’;

    That seems like a limitation/shortcoming in EE and MSM, is it?

    If I had a record for www. going to ip or an A record and then set this to:

    $assign_to_config[‘site_url’] = ‘http://www.clientdomainname.com’;

    then I would just have the opposite issue with EE… the non www version would not come up?

    This site error (which is is pretty vague and impossible to troubleshoot…) that is thrown is inappropriate then and should state something about configuration more than error if its expected and if in fact this is how it works aka an MSM domain can only point to one url in ones single EE instance…

  • #6 / Nov 21, 2011 10:51am

    Robin Sowell

    13255 posts

    Hrm- there’s nothing about MSM per se that precludes loading www vs. not.  The site_url is just going to affect EE generated links, not the path it’s using to find the config file (which is what is causing that ‘Can’t find’ error.  Is it possible to link to the msm site that fails w/www?  I want to take a look at the headers when you get the failure to load message.  If it needs to be kept private, you can email me at .(JavaScript must be enabled to view this email address).

  • #7 / Nov 21, 2011 11:12am

    davey

    27 posts

    Hi Robin,

    Thanks for the reply and the support on this…

    So, in the index.php when using MSM, whether you indicate to have your MSM site go to a www. site or same site without the www. - the index.php will handle anything going to that url with or without the www?

    It seems like I had issues with my site_url prior basically not rendering out correctly and I wonder if that is more of the problem than anything? Like some url setting to something in system administration is wrong?

    I can share the link(s) but I have temporarily altered my DNS to get around www. allegedly not being handled appropriately. I also did a fresh install of 2.3.1 but this issue I think is still there… I thought maybe my instance or config or something was just haywire, so just reinstalled… Its a workaround, but I just want it to work as designed so I can head off any future issues due to something else being misconfigured or something…

    I will email you some links to check the headers here today…

    thanks,

    David

  • #8 / Nov 21, 2011 11:27am

    davey

    27 posts

    Waiting for DNS to update to try and recreate how that was set…

    This whole thing is just weird, the bottomline/recap here is both www. and not www. on the domain were handled correctly through DNS as they both got to their destination point the index.php file. But when they hit the index.php file or the config file or whatever the order is - www. got handled correctly and the other gave that error…

    Hopefully I can recreate the situation on 2.3.1 and see if I can recall what I had the www. doing in the DNS correctly…

    thanks,

    David

  • #9 / Nov 21, 2011 12:02pm

    Robin Sowell

    13255 posts

    Yea- definitely odd.  I dug a bit more and suspect it’s getting the wrong site_name somehow.  You can see what it’s using if you edit system/ee/core/EE_Config.php around line 214.  It looks like:

    if ($query->num_rows() == 0)
      {
       if ($site_name == '' && $site_id != 1)
       {
        $this->site_prefs('', 1);
        return;
       }
    
       exit("Site Error:  Unable to Load Site Preferences; No Preferences Found");
      }

    Change the exit line to show what it’s using for the site name:

    exit("Site Error:  Unable to Load Site Preferences; No Preferences Found for: ".$site_name);

    Why the heck it’s seeing site_name differently baaed on the url… I’m not sure.

  • #10 / Nov 21, 2011 12:08pm

    davey

    27 posts

    Cool I will investigate that…

    So, site_name and site_url - how do they relate in an MSM setup?

    Because back here in Sept, I had issues getting site_url to end up at the right directory or it was issue not getting a trailing forward slash and thus path wouldn’t work: http://ellislab.com/forums/viewthread/200149/

    Just trying to understand and see what else might be related… 😉 not drag this out…

    best -

    David

  • #11 / Nov 21, 2011 12:32pm

    Robin Sowell

    13255 posts

    site_name in the index.php file is critical- it’s what’s used to identify the site and thus gather up all of the preferences held in the exp_sites table.  The site_url is way less important.  If you get that wrong?  You’ll have some bad links and it may prove annoying.  But the site itself should pull up fine.  If the short name doesn’t match up?  You can’t load your settings.

  • #12 / Nov 21, 2011 12:51pm

    davey

    27 posts

    Ok cool. Yea site_name importance is clear. Sorta unrelated query here, but I believe I read in the EE manual that in MSM setups site_url does not reference each MSM site or there is some difference? That is defined in system administration per each MSM site right?

    So the preferences the error is referencing are the ones in exp_sites? like they aren’t there or being found for the www. link (weirdly), yet the same short site name is being used (presumably) since it is the only one in the index.php file…

    Once dns updates I am hoping I can get that error to come up and verify the short site name is appearing consistently by adjusting the code as you suggested above…

  • #13 / Nov 21, 2011 3:08pm

    Robin Sowell

    13255 posts

    The site_url is basically an override for site pref- er, it’s what will show in the {site_url} global- but it’s also relevant for redirects and such.  In other words- it needs to be correct, but it won’t cause the issue you’re seeing.

    And yep- the prefs it can’t find are in exp_sites- and it’s trying to find them based on the site short name specified in that index.php file.  The fact it can’t is… curious.  Definitely let us know what you get on that output tweek- hopefully it will give us a hint as to what the heck it’s looking at when it tries to pull the short name.

  • #14 / Jun 05, 2012 7:16pm

    femke

    2 posts

    Changing:

    $query = $EE->db->get_where(‘sites’, array(‘site_name’ => $site_name));

    ...into this:

    $query = $EE->db->query(“SELECT * FROM exp_sites WHERE site_name=’$site_name’”);

    ... solved the problem for me.

  • #15 / Jun 08, 2012 6:21pm

    Shane Eckert

    7174 posts

    Hey femke,

    Thanks for the info!

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases