Unusual use-case - but I have a client with two websites they're merging into one. Their aim is to make the Craft 3 site (currently on its own top level domain) run in a /distribution sub folder.

I've managed to get this largely working by using the apache alias command:

Alias /distribution "/path/to/craftsite/web/"

and updating the site .env and config file to have the /distribution/ folder on the end of the DEFAULT_SITE_URL.

The site now loads but struggles loading CSS, JS and images as it's looking for these at the higher level than the /distribution folder which is aliased.

Is there an easy way to add a prefix to the path Craft is loading all the assets from?

  • Is this about the public assets or the cpresources for the backend? Commented Aug 26, 2021 at 15:58
  • Public assets so far (I may yet encounter issues with cpresources further through testing though...).
    – steve
    Commented Aug 26, 2021 at 16:43

1 Answer 1


I found the solution after a lot of poking and prodding:

'aliases' => [
    '@assetBaseUrl' => '/distribution/assets/',
    '@assetBasePath' => '/path/to/the/assets/',

Added into the general.php file in config did the magic.

I still needed to alias the imager folder but all seems to be working well now in a sub-folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.