I'm completely running stuck at the moment. In first place I had an issue that if I typed www.mydomain.nl, the user always was redirected to mydomain.nl. No idea why and I wanted to force the user to access the site with www. in the URL. So started looking at this an somehow (without changing a thing I believe), I can now access the site with www. in the URL, so not being redirected anymore.

However, I'm now getting a Site Error if I access the site when using the URL with www. in front of it. But the site is working fine without the prefix. I don't understand it anymore.

Working: http://domain.nl

Not working: http://www.domain.nl.

Giving this error:

An Error Was Encountered
Site Error: Unable to Load Site Preferences; No Preferences Found

.htaccess file which is unchanged:

RewriteEngine On

# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

If I search for this error, I mostly reed about database errors. But how would a www in the URL break up a database connection.

database.php file in system/expressionengine/config/

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$active_group = 'expressionengine';
$active_record = TRUE;

$db['expressionengine']['hostname'] = 'localhost';
$db['expressionengine']['username'] = 'someUser';
$db['expressionengine']['password'] = 'thePassword';
$db['expressionengine']['database'] = 'someDatabase';
$db['expressionengine']['dbdriver'] = 'mysql';
$db['expressionengine']['pconnect'] = FALSE;
$db['expressionengine']['dbprefix'] = 'exp_';
$db['expressionengine']['swap_pre'] = 'exp_';
$db['expressionengine']['db_debug'] = TRUE;
$db['expressionengine']['cache_on'] = FALSE;
$db['expressionengine']['autoinit'] = FALSE;
$db['expressionengine']['char_set'] = 'utf8';
$db['expressionengine']['dbcollat'] = 'utf8_general_ci';
$db['expressionengine']['cachedir'] = 'system/expressionengine/cache/db_cache/';

/* End of file database.php */
/* Location: ./system/expressionengine/config/database.php */
  • 1
    Are you using Master Config? If so, you'll need to add the www domain separately to your environment file. Mar 6 '14 at 13:36
  • @JeremyGimbel, No, I'm not using that. Should I?
    – Timo002
    Mar 6 '14 at 13:37
  • 1
    Not necessarily. Can you edit your question to show your database.php config file? Please replace all the usernames and passwords with fake values. Mar 6 '14 at 13:57
  • @JeremyGimbel, updated my question with the database.php file!
    – Timo002
    Mar 6 '14 at 14:00
  • Ok that's odd. I was expecting that you'd have some code that was changing the database based on the hostname. The error you're getting is because EE can't connect to the database. Mar 6 '14 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.