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.

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

1 Answer 1

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.

5
  • 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? Apr 29, 2013 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? Apr 29, 2013 at 20:52
  • If you use htaccess to force www or non-www, you will avoid this problem completely in the first place. Apr 29, 2013 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. Apr 30, 2013 at 1:48
  • Thanks guys. That fixed my issues. Very much appreciated. May 1, 2013 at 19:04

Your Answer

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

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