I've imported a craft install and its database from a production site to make some changes to it. I've set it up to work locally in MAMP but whenever I go to example.local it keeps redirecting me to example.com. I'm using a multi-environment config so I'm not sure where it could be going wrong.

return array(

// Applies to all enviroments
'*' => array(

    // Base site URL
    'siteUrl' => null,

    // Environment-specific variables (see https://craftcms.com/docs/multi-environment-configs#environment-specific-variables)
    'environmentVariables' => array(),

    // Default Week Start Day (0 = Sunday, 1 = Monday...)
    'defaultWeekStartDay' => 0,

    // Enable CSRF Protection (recommended, will be enabled by default in Craft 3)
    'enableCsrfProtection' => true,

    // Whether "index.php" should be visible in URLs (true, false, "auto")
    'omitScriptNameInUrls' => 'auto',

    // Control Panel trigger word
    'cpTrigger' => 'admin',

    // Dev Mode (see https://craftcms.com/support/dev-mode)
    'devMode' => false,

    // Preserve Image’s Colour Profiles 
    'preserveImageColorProfiles' => true


// Applies just to local dev server
'.local' => array(
    // Site URL
    'siteUrl' => "http://example.local:8888/",

    // Devmode
    'devMode' => true,

    // Turn off timeout
    'userSessionDuration' => false,

    // Image assets paths
    'environmentVariables' => array(
        'basePath' => '',
        'baseUrl'  => 'http://example.local:8888/',

// Applies to production site
'.com' => array(
    // Site URL
    'siteUrl' => "http://example.com/",
    // Devmode
    'devMode' => false,

    // Image assets paths
    'environmentVariables' => array(
        'basePath' => '',
        'baseUrl'  => 'http://example.com/',

And my current .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On

# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]

  • Anything weird regarding redirects in your .htaccess file? Is it perhaps redirecting everything immediatly to your TLD? Apr 27, 2018 at 7:13
  • Good spot @GįëłTėttëłæår. I had a rewrite rule to get rid of www. from URLs which was going to the TLD but weirdly even when I remove that from the .htaccess I'm still getting redirected... Apr 27, 2018 at 18:55
  • Working now, just had to delete my browser cache. Thanks! Apr 27, 2018 at 20:00
  • Glad to hear its fixed! Apr 30, 2018 at 19:47

1 Answer 1


There was a rule in my .htaccess to remove www that was redirecting to the live production site. Once I removed that I needed to delete my browser cache.

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.