0

We're using EE and I'm also using the Focus Lab Multi Environment Config file on one of our sites and for some reason our site won't work with WWW at the start of the address.

I have confirmed with the hosting provider that everything is correct from their end, but am confused as to where to move from here.

Is there something in the config file that should be modified to make this work again?

Very new to the Focus Lab Config file.

  • What hosting provider are you with? Can you show us your .htaccess file contents? – Stephen Callender Apr 29 '13 at 17:46
  • Sounds like an .htaccess error, can you show the .htaccess file or the parts related to EE. – nonprofit_tech Apr 29 '13 at 20:22
  • Hi Guys. I actually don't have a .htaccess file at root. Do I need one? – Mark Dodgson Apr 29 '13 at 20:51
3

In your Focus Lab Config config.env.php file, you might need to make sure that both www and non www are specified in the switch statement.

switch ($_SERVER['HTTP_HOST']) {
  case 'website.com' :
  case 'www.website.com' :
    define('ENV', 'prod');
    define('ENV_FULL', 'Production');
    define('ENV_DEBUG', FALSE);
  break;

  ...
}

But saying that, you should really only be using one or the other. Being able to access the site using www and non-www will lead to duplicate content on Google. Not good.

Your htaccess needs to have something like this to force the removal of www.

<IfModule mod_rewrite.c>
  RewriteEngine On 
  RewriteBase /  
  RewriteCond %{HTTP_HOST} ^www\.website\.com$ [NC]
  RewriteRule ^(.*)$ http://website.com/$1 [R=301,L]
</IfModule>

There are many different ways to do it and you can find plenty of resources on how to do it.
Here's one on how to force www.

| improve this answer | |
  • Yup... That did it, thanks for your help. I can't be the only one who has run into this. Is there a better way. I have 2 sites running the focus Lab config file and it's doing the same thing on both. I don't want to have duplicat content problems. Any thoughts? – Mark Dodgson Apr 29 '13 at 20:40
  • I just tried your suggestion on the 2nd site and it doesn't seem to work. I was great on the first though. Very confused. Any thoughts? – Mark Dodgson Apr 29 '13 at 20:52
  • If you use htaccess to force www or non-www, you will avoid this problem completely in the first place. – Jason Varga Apr 29 '13 at 22:26
  • 1
    You can simplify the code even more by removing the WWW from the switch statement. switch (str_replace('www.', '', $_SERVER['HTTP_HOST'])). This will ensure you only have to define the case once, and it works with all the environments. – Justin Kimbrell Apr 30 '13 at 1:48
  • Thanks guys. That fixed my issues. Very much appreciated. – Mark Dodgson May 1 '13 at 19:04

Your Answer

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

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