0

I've developed my site locally and now need to migrate to staging. The Home page is displaying correctly so I would assume that a database connection is not the issue. But requesting {staging_url}/{any_segment} results in a 500 Internal Server error.

Here I'm setting the environment in index.php:

if (substr($_SERVER['SERVER_NAME'], -strlen('.dev')) === '.dev') {
    define('CRAFT_ENVIRONMENT', 'development');
} else if ($_SERVER['SERVER_NAME'] == 'staging.blah.com') {
    define('CRAFT_ENVIRONMENT', 'staging');
} else {
    define('CRAFT_ENVIRONMENT', 'production');
}

Here's my general.php:

return array(
    '*' => array(
        'extraAllowedFileExtensions' => 'vcf',
        'omitScriptNameInUrls' => true,
    ),
    'development' => array(
        'devMode' => true,
        'siteUrl' => 'http://blah.dev',
        'environmentVariables' => array(
            'baseUrl' => 'http://blah.dev',
        ),
    ),
    'staging' => array(
        'siteUrl' => 'http://staging.blah.com',
        'environmentVariables' => array(
            'baseUrl' => 'http://staging.blah.com',
        ),
    ),
    'production' => array(
        'siteUrl' => 'http://blah.com',
        'environmentVariables' => array(
            'baseUrl' => 'http://blah.com',
        ),
    ),
);
4
  • I don't know if it's the cause of your issue, but if (substr($_SERVER['SERVER_NAME'], -strlen('.dev')) === '.dev' !== FALSE) isn't valid PHP syntax.
    – Brad Bell
    Commented Sep 3, 2015 at 22:37
  • Ha I shortened that line before posting because it caused a wrap in the preview- I thought I had the right syntax but I guess not. Anyway, I don't think that's it. Can you please help me understand the difference between siteUrl and baseUrl? Also, could this possibly be due to a bad Settings > General > Site URL value when I did the db export / import? I added the siteUrl override after the migration.
    – plaintxt
    Commented Sep 4, 2015 at 1:23
  • This has something to do with index.php being absent in the requested URL.
    – plaintxt
    Commented Sep 4, 2015 at 2:25
  • @subtlegusto Could you add your fix as an answer so this question is marked as answered/complete. Thanks :)
    – j00lz
    Commented Sep 4, 2015 at 2:33

1 Answer 1

2

This is solved by this thread.

The common thread here is Rackspace Cloud Sites, which apparently needs a RewriteBase / instruction in .htaccess.

Thanks @maxx and @christopher-healey

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