Craft CMS domain setup

Published

Updated

Craft CMS takes its site URL from the PRIMARY_SITE_URL ENV var. The software template sets it on fortrabbit. A multi-site setup uses one ENV var per site.

Site URL

Craft's installer writes the local site URL into the .env file as PRIMARY_SITE_URL and uses $PRIMARY_SITE_URL as the base URL of the primary site. The .env file stays local. The Craft CMS software template sets this ENV var in the ENV vars of the environment:

PRIMARY_SITE_URL=https://${FORTRABBIT_MAIN_DOMAIN}
shell

Apps created before November 2026 don't have it. Add it by hand to the ENV vars of each environment.

FORTRABBIT_MAIN_DOMAIN holds the main domain chosen for the environment. All domains of an environment share its root path, web for Craft CMS.

Multi-site domains

Give each site its own ENV var, for example SITE_URL_EN and SITE_URL_NL, and enter $SITE_URL_EN as the base URL of that site under Settings → Sites in the local control panel. Set the local values in .env and the fortrabbit values in the ENV vars of the environment:

SITE_URL_EN=https://www.example.com
SITE_URL_NL=https://www.example.nl
shell

Add all domains to the environment. Craft routes each request to the site whose base URL matches. Use .htaccess rules for redirects between the domains.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗