When my multisite is set up as @web/site, I cannot access the current site handle from my controllers.


I think this is because my form action defaults to the root site ie @web/actions/controller... rather than @web/site/actions/controller...

Is there a way to get the current site or do I need to pass it into the controller from the form?

  • Why doesn't Craft::$app->getSites()->currentSite->handle work? What is it returning for you?
    – Brad Bell
    Commented Aug 29, 2018 at 23:47
  • It is returning the default site handle. I have a domain name example.com and multisites set up as example.com/site1 and example.com/site2. The controller gets called from example.com/actions/controller therefor retuning example as the site handle and not site1 or site2. Commented Sep 10, 2018 at 1:12
  • I'm having the same problem. Did you ever figure this out?
    – Ryan
    Commented Mar 17, 2020 at 14:25

2 Answers 2


I know this is a year and a half late, but maybe it helps someone else. I have a large multi-site project with a site for country and language. For example:

  • Germany (German) - default - /de-de/
  • Germany (English) - /en-de/
  • Austria (German) - /de-at/
  • Austria (English) - /en-at/
  • etc

I was having this problem when posting to one of my controller's actions and then trying to get the currentSite within my plugin via Craft::$app->getSites()->currentSite.

In my JavaScript, my action looked like:


Whenever I'd fetch the current site with Craft::$app->getSites()->currentSite it would always return the default site (Germany/German), and that's because I wasn't including the first URL segment (to get Austria/English, for example):


Without that, Craft was resorting to getting the default site.


With Craft CMS 3, you can spit out current site values directly with currentSite.

Site ID:            {{ currentSite.id }}
Site Handle:        {{ currentSite.handle }}
Site Name:          {{ currentSite.name }}
Site Language:      {{ currentSite.language }}
Is Primary Site?:   {{ currentSite.primary }}
Base URL:           {{ currentSite.baseUrl }}


  • Question was about controllers; not twig.
    – biko
    Commented Jul 7, 2023 at 6:00

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.