# Can I set the Aurelia root based upon browser URL/subdomain?

**URL:** <https://discourse.aurelia.io/t/can-i-set-the-aurelia-root-based-upon-browser-url-subdomain/4037>\
**Category:** Help Requests\
**Created:** [February 15, 2021, 11:17am UTC](https://discourse.aurelia.io/t/can-i-set-the-aurelia-root-based-upon-browser-url-subdomain/4037 "2021-02-15T11:17:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jochenf](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jochenf](https://discourse.aurelia.io/u/jochenf)\
**Post date:** [February 15, 2021, 11:17am UTC](https://discourse.aurelia.io/t/can-i-set-the-aurelia-root-based-upon-browser-url-subdomain/4037/1 "2021-02-15T11:17:06Z")

</div>

Hi,

I have a (secured) aurelia application that is accessed through [https://app.mydomain.be](https://app.mydomain.be) and would like to build a public part to this application which does not require any authentication, eg. [https://pub.mydomain.be](https://pub.mydomain.be). As I want to re-use my (UI) libraries, I’d like to have 1 aurelia application that is able to pick the right root based on the URL the client is using…

So :

app.mydomain.be → setRoot(“private-root”)  
pub.mydomain.be → setRoot(“public-root”)

Is this possible?  
Any help on this would be very welcome… 🙂

Thank you.

Jochen

---

<div class="post-metadata">

**Author:** ![ormasoftchile](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/ormasoftchile/32/340_2.png) [@ormasoftchile](https://discourse.aurelia.io/u/ormasoftchile)\
**Post date:** [February 15, 2021, 1:54pm UTC](https://discourse.aurelia.io/t/can-i-set-the-aurelia-root-based-upon-browser-url-subdomain/4037/2 "2021-02-15T13:54:04Z")

</div>

Yes, it is possible.  
You should decide in the main module which application root is run.  
For example:

```
let startModule = 'modules/public/public-app';

```

if (authService.isAuthenticated) {  
startModule = ‘modules/private/private-app’;  
}  
…  
return aurelia.setRoot(startModule);

In your case, you could choose your application root by inspecting window.location.href

Best regards

---

<div class="post-metadata">

**Author:** ![jochenf](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jochenf](https://discourse.aurelia.io/u/jochenf)\
**Post date:** [February 15, 2021, 2:45pm UTC](https://discourse.aurelia.io/t/can-i-set-the-aurelia-root-based-upon-browser-url-subdomain/4037/3 "2021-02-15T14:45:53Z")

</div>

> [@ormasoftchile](#):
>
> window.location.href

Thanks @ormasoftchile this will probaby work!!

Jochen
