November Happy Hour will be moved to Thursday December 5th.

Multi-site favicons for siteassets

Vote:
 

Hi all,

We are running Episerver v11.5.1 on DXC in a multi-site environment.

We are able to serve different icon for each site by storing the icon in different paths for each site. This works fine for website pages.

But when we serve assets from /siteassets , say for example when someone opens a PDF in their Browser from the Search Results page, the favicon.ico is served from the root /favicon.ico

We have seen issues with 404's if there is no root favicon.ico, so we have placed a generic/empty looking favicon.ico in the root for now.

Can someone please explain how it is possible to serve a different favicon for different sites for /siteassets?

I did have a read of this post. Maybe a rewrite rule is possible on DXC based on domain name?
https://world.episerver.com/forum/User-Forum/Functionality-in-Episerver/Thread-Container/2015/8/multiple-favicons/


#206877
Edited, Sep 03, 2019 9:09
Vote:
 

Hi Darren,

I tend to go for the URL rewrite approach. Something like this:

<rewrite>
  <rules>
    <rule name="Favicon Site 1">
      <match url="^favicon.ico$"/>
      <conditions>
        <add input="{HTTP_HOST}" pattern="^mysite1.com$" negate="false" />
      </conditions>
      <action type="Rewrite" url="/favicons/site1.ico"/>
    </rule>
  </rules>
</rewrite>

If you need more logic than the rewrite rules allow, you could tie in to the Application_BeginRequest event in an HTTPModule or global.asax at which point you can do whatever you need to establish the correct favicon and to swap it out using Context.RewritePath().

#206886
Sep 03, 2019 12:03
Vote:
 

Hey Paul thanks for your rewrite rule.

I was hoping to avoid the need for a developer to update the rewrite rules and deploy code when a new site gets added. It feels a little odd that there is an Admin UI that allows you to create a new Site but there are still some things that need code changes.

It's a pretty minor issue, I'm not sure if it's worth finding a more dynamic solution. We have had some new Sites added on Production recently that have 100% reuse of code, but that is quite rare, I think most new sites include some new code, we'll just need to include updating the rewrite rules as a task for each new site.


Thanks again.

#206916
Edited, Sep 04, 2019 2:36
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.