How to Access the Control Panel from a Subdomain

If you’d like to access Craft’s Control Panel from a subdomain, follow these steps:

1. Configure the subdomain on your server. #

Have your server route requests for <subdomain> to the same web root (e.g. your web/ folder) as your main site.

Once that’s configured correctly, you should be able to access your Control Panel from https://<subdomain> (If you’ve given your site a custom CP trigger word, replace admin with that.)

2. Tell Craft to redirect Control Panel requests to your subdomain. #

If someone accesses the Control Panel from, you can have Craft automatically redirect them over to your subdomain with the baseCpUrl config setting.

Open up config/general.php and add that setting to your production environment’s config:

'production' => [
    'baseCpUrl' => 'https://<subdomain>',
    // ...

The base CP URL should not include the CP trigger word (e.g. /admin).

If you’d prefer to define the base CP URL using an environment variable, you can add the baseCpUrl to the default environment config instead:

# -- .env --
// -- config/general.php --
'*' => [
    'baseCpUrl' => getenv('BASE_CP_URL') ?: null,
    // ...

With that in place, any time Craft needs to generate a URL to the Control Panel (such as when redirecting users to the Login screen), it will take your baseCpUrl into account rather than building the URL based on the requested URL.