what about if you are on a multi site install, where would you put the favicon to have it automaticallly recognized by the browser (and no blot the code with link tag)cause there is no real root per se?

Thank you in advance for your help on this

  • Thank you for the link, but the very reason of this post is because I previously posted my question on this thread but it has been deleted because it was off topi Jan 14, 2012 at 19:20
  • Just drop it in the same folder as WordPress - that's your root (unless you've got it installed in a subfolder). Jan 14, 2012 at 19:53
  • @theDeadedic thank you for your answer, but in a context of multi site install, what would be considered as root. let say that I have 10 sites under the network belt, where would you put those 10 different favicon? Jan 15, 2012 at 5:31
  • So, just to be clear, each site has a different favicon? Jan 15, 2012 at 11:15

2 Answers 2


I would use a rewrite to map requests for /favicon.ico to /icons/example.com.ico:

RewriteCond %{REQUEST_URI} ^/favicon\.ico
RewriteCond %{SERVER_NAME} ^(www\.)?([a-z0-9]+)
RewriteCond %{DOCUMENT_ROOT}/icons/%2.ico -f
RewriteRule . /icons/%2.ico [L]

Note the regex for line #2 depends on your set-up - is each website its own domain, or a subdomain/subdirectory of a primary domain?

I would also place a default favicon in the root, which will get pulled if no favicon exists in /icons for the current site.


Another approach is to print the links in the <head>.
The only caveat is that the following is not working in Sub-directory installs, only in Sub-domain.
Somehow get_current_blog_id is only returns the ID 1 in when define('SUBDOMAIN_INSTALL', false);.

 * Plugin Name: Multisite Favicons
 * Description: Favicons should be stored in http://example.com/icons/domain_name.ico | If the site is subsite.example.com, the favicon should be subsite.ico

add_filter( 'wp_head', 'multisite_favicons_wpse_38903' );

function multisite_favicons_wpse_38903()
    // This function returns true if not Multisite
    if( is_main_site() ) 

    global $current_site;

    $details = get_blog_details( get_current_blog_id() );
    $blogname = 
        ( is_subdomain_install() ) 
        ? str_replace( '.' . $current_site->domain, '', $details->domain ) 
        : $details->path;

        "<link rel='shortcut icon' href='%s/icons/%s.ico' type='image/x-icon'/>\n", 

Interesting blog post: Everything You Ever Wanted to Know about Favicons

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.