Skip to content

Instantly share code, notes, and snippets.

@frostbitten
Created July 22, 2016 00:37
Show Gist options
  • Save frostbitten/980f8719a90b38a7eb5002a186cb6260 to your computer and use it in GitHub Desktop.
Save frostbitten/980f8719a90b38a7eb5002a186cb6260 to your computer and use it in GitHub Desktop.
$app->get('/css/fonts/fontawesome-(:type)?', function ($type) use ($app) {
$v = $app->request->get()['v'];
$app->redirect('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/'.$v.'/fonts/fontawesome-'.$type, 301);
});
@frostbitten
Copy link
Author

this works because fontawesome declares this route (including the version number in the query parameters) for font files.

See here:

@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?v=4.6.3');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.3') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.6.3') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.6.3') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.6.3') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.6.3#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

This might not work in one case

but I'm really not sure:

url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.3') format('embedded-opentype'),
See the # mark?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment