The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

favicon.ico

Discussion in 'General Discussion' started by ozzieonline, Jan 15, 2013.

  1. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Hello,

    My Apache log is filling with error messages that "favicon.ico" can not be found. I did some researching and found out that a browser makes a request in the document root for "favicon.ico". So that's what's triggering all these error messages. I use add-on domains in combination with templates. Therefore I set the Document Root of each website (add-on domain) to public_html. I do this, so each website can use template files. Website specific files (for example favicon.ico) will be placed in a subfolder that corresponds with the website.

    Something like this:

    Code:
    .../public_html/templates/css
                             /images
                             /etc.
                   /website1/css
                            /images/favicon.ico
                            /etc.
                   /website2/css
                            /images/favicon.ico
                            /etc.
    
    What I could do is place an empty favicon.ico in the public_html root. However I'm afraid that this favicon then will be showed for all websites, instead of the correct site-specific favicon located in one of the subfolders.

    Another solution I read on the internet, was using this rule:

    Redirect 404 /favicon.ico

    This way the error messages wouldn't show up in the error log. Someone else suggested that this is not a good idea, because this would cause errors to search engines who spider your website. Instead he suggested to redirect to a 200 (ok) header. I assume it's like this:

    Redirect 200 /favicon.ico

    Now, I wonder... is this a good solution to stop the error messages from appearing in the Apache error log?
     
    #1 ozzieonline, Jan 15, 2013
    Last edited: Jan 15, 2013
  2. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    Orlando, FL
    cPanel Access Level:
    Root Administrator
    favicons are looked for at the root of the domain unless otherwise specified in the HTML.

    So, you could always edit the templates for your sites to add these lines to the HEAD of the output HTML.

    <link rel="icon" href="/website1/images/favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="/website1/images/favicon.ico" type="image/x-icon" />
     
  3. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks kdean. I will do that.. but it will take a while before my templates are finished. I'm just starting to build my framework.

    Can I do this to redirect to a 200 header if the favicon in public_html is requested? Can I enter an absolute path?

    Redirect 200 /home/myaccount/public_html/favicon.ico

    Will that work?
     
    #3 ozzieonline, Jan 15, 2013
    Last edited: Jan 15, 2013
  4. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    Orlando, FL
    cPanel Access Level:
    Root Administrator
    I'm not sure what redirecting to itself at the root would accomplish since it would return text instead of an image to the browser or search engine and may cause other issues. Why not just put a temporary favicon.ico at the public_html root and then when the templates are ready with the link tags, they'll override.

    If Redirected, the absolute path would not work, just the domain root relative path would suffice.

    Redirect 200 /favicon.ico
     
  5. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks kdean.

    So "/favicon.ico" in Redirect 200 /favicon.ico refers to the root directory?

    What if I use this rule for now... then if the browser tries to request the favicon it gets a 200 header. Is that a bad thing? At least it won't be logged then I assume? If my templates are ready in a while then the favicon won't be requested anymore, so no problem.

    Should I just try it?
     
  6. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    Orlando, FL
    cPanel Access Level:
    Root Administrator
    yes /favicon.ico is at the root.

    Might as well just try it. You shouldn't see it in an error log.
     
  7. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Allright, then I'll just try it. Wouldn't hurt I think. Thanks!
     
Loading...

Share This Page