Do I need to have a favicon on my site? How do I get rid of the errors I see in my apache log?

后端 未结 7 1244
余生分开走
余生分开走 2021-02-18 21:48

I keep seeing favicon warnings in my apache log. How do I get rid of those? Do I have to have a favicon for my site?

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-18 21:59

    You don't really need it, but as others have said, some browsers will ask for it even if it's not specified in .

    I'm not an expert, but I played with mod_rewrite a bit, and here's what you can do:

    # turn on the mod_rewrite module
    RewriteEngine On
    # if requested file is not an existing file
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
    # and it's name is favicon.ico, send an empty 410 GONE response to the browser
    RewriteRule .*favicon\.ico$ - [G] 
    

    I only tried this on my localhost: first request resulted in 410, but for all following ones, browser does not ask for that file, because it remembers it's gone.

    I'm not sure this is how you're supposed to use 410 GONE status, nor that it will work 100%.

提交回复
热议问题