Modern favicons & htaccess rewrite rule

前端 未结 1 333
时光说笑
时光说笑 2020-12-22 02:15

Instead of having all the new favicon formats placed into the root directory of my website, I am placing them inside a subfolder.

To conform to the standards, as som

相关标签:
1条回答
  • 2020-12-22 02:50

    Modern favicons + Rewrite

    Following is a fairly robust pattern for mapping the modern favicon's using rewrite.

    Regex pattern, for reference

    ^(browserconfig.xml|manifest.json|safari-pinned-tab.svg|(android-chrome|favicon|mstile)-[0-9]+x[0-9]+.png|apple-touch-icon(-precompressed.png|-[0-9]+x[0-9]+.png|.png)|manifest.json)$

    Usage: apply it to a rewrite rule (htaccess)

    This example assumes the rewrite destination where the favicon's are placed is a folder named favicon (or whatever folder you wish).

    RewriteRule ^(browserconfig.xml|manifest.json|safari-pinned-tab.svg|(android-chrome|favicon|mstile)-[0-9]+x[0-9]+.png|apple-touch-icon(-precompressed.png|-[0-9]+x[0-9]+.png|.png)|manifest.json)$ /favicon/$1 [L]
    
    0 讨论(0)
提交回复
热议问题