How Craft Determines the Site URL

When Craft is determining the Site URL (such as to set the value of the siteUrl global variable), it will check the following locations, in this order:

  1. The siteUrl config setting

    If this is set to a string, that value will be used. If it’s an array, Craft will check if the array contains a value for the current locale, and use that if so. Otherwise the first value in the array will be used. This is the recommended way to set your Site URL.

  2. The CRAFT_SITE_URL PHP constant

    If this is defined, Craft will parse it for environment variables and use the result.

  3. The Site URL setting in the Control Panel’s general settings

    This is the URL that you chose when installing Craft, and can be edited from Settings → General. Craft will parse it for environment variables and use the result.