# Custom redirect handling from root

**URL:** <https://forum.litium.com/t/custom-redirect-handling-from-root/854>\
**Category:** Questions\
**Created:** [May 14, 2019, 4:40pm UTC](https://forum.litium.com/t/custom-redirect-handling-from-root/854 "2019-05-14T16:40:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas3133](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@Andreas3133](https://forum.litium.com/u/Andreas3133)\
**Post date:** [May 14, 2019, 4:40pm UTC](https://forum.litium.com/t/custom-redirect-handling-from-root/854/1 "2019-05-14T16:40:13Z")

</div>

I’m wondering if there’s any way to control the redirect that happens when you visit the root of the site to the default website. For example: [mydomain.com](http://mydomain.com) -\> [mydomain.com/sv](http://mydomain.com/sv).

The reason is we’re using multiple sites where some are not related, so you could say we have more than one default site. Since Litium 6 only seems to support one default site, we want to handle this redirection logic by ourselves.

A more detailed example of what we’re trying to do:  
We have 4 sites:  
[mysite1.com/sv](http://mysite1.com/sv)  
[mysite1.com/en](http://mysite1.com/en)  
[mysite2.com/sv](http://mysite2.com/sv)  
[mysite2.com/en](http://mysite2.com/en)

If you go to [mysite1.com](http://mysite1.com), you should end up at [mysite1.com/sv](http://mysite1.com/sv). But if you try to visit [mysite2.com](http://mysite2.com), you should end up at [mysite2.com/sv](http://mysite2.com/sv).

Litium version: 6.1.1

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [May 14, 2019, 8:04pm UTC](https://forum.litium.com/t/custom-redirect-handling-from-root/854/2 "2019-05-14T20:04:13Z")

</div>

For Litium 6 you need to create a separate website (set the website as default website) that will act as the landing page for the different domains and redirect the user to the correct page.

---

<div class="post-metadata">

**Author:** ![anders.bjornasen](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@anders.bjornasen](https://forum.litium.com/u/anders.bjornasen)\
**Post date:** [May 20, 2019, 5:41pm UTC](https://forum.litium.com/t/custom-redirect-handling-from-root/854/3 "2019-05-20T17:41:15Z")

</div>

Where would be the correct place to intercept the URL and create the redirect? We have an authorization filter (implementing IAuthorizationFilter) which we use to force a logged in customer to the correct site. It also handles not logged in customers by determining which language site would be the correct site for the customer, based on IP and language settings.  
However, Litium seems to intercept the call before IAuthorizationFilter.OnAuthorization gets called, so there is no way for us to see which URL that caused Litium to redirect to the default web site.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [May 22, 2019, 7:23am UTC](https://forum.litium.com/t/custom-redirect-handling-from-root/854/4 "2019-05-22T07:23:18Z")

</div>

Litium uses an own registered `System.Web.Routing.RouteBase` that handle the dynamic translation of the URL. The `RouteBase` then return the correct handler depend on web forms of mvc that should handle the current request, if that is an mvc handler the normal mvc pipeline will be triggered with your filter.

If you need to intercept the url before we do anything with it, you need to do that by an own `RouteBase`-route registered before Litiums route start processing the url.

---

<div class="post-metadata">

**Author:** ![anders.bjornasen](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@anders.bjornasen](https://forum.litium.com/u/anders.bjornasen)\
**Post date:** [May 23, 2019, 4:30am UTC](https://forum.litium.com/t/custom-redirect-handling-from-root/854/5 "2019-05-23T04:30:53Z")

</div>

Thanks. Initial tests show that the suggested approach works fine. It also means that I don’t need a special default site that just acts as a landing page, which is a bonus.
