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',
        ),
    ),
);
plaintxt
  • 488
  • 3
  • 15
  • 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 Sep 03 '15 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 Sep 04 '15 at 01:23
  • This has something to do with index.php being absent in the requested URL. – plaintxt Sep 04 '15 at 02:25
  • @subtlegusto Could you add your fix as an answer so this question is marked as answered/complete. Thanks :) – j00lz Sep 04 '15 at 02:33

1 Answers1

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

plaintxt
  • 488
  • 3
  • 15