From 5a2a7927c0b0bc98d8a67dd07518bbcd97840e7c Mon Sep 17 00:00:00 2001 From: Vincent Orback Date: Mon, 16 Feb 2015 16:40:38 +0100 Subject: [PATCH 1/2] Added snippet for "Serving WebP images" --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 967ee3e..6c55abc 100644 --- a/README.md +++ b/README.md @@ -425,3 +425,16 @@ AddHandler application/x-httpd-php55 .php # Alternatively, you can use AddType AddType application/x-httpd-php55 .php ``` + +### Serve WebP images +If WebP images are supported and an image with a .webp extension is located as the same place as the jpg/png image that is going to be served, then the WebP image is served instead. + +``` apacheconf + + RewriteEngine On + RewriteCond %{HTTP_ACCEPT} image/webp + RewriteCond %{DOCUMENT_ROOT}/$1.webp -f + RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1] + +``` +[Source](https://github.com/vincentorback/WebP-images-with-htaccess) From c54927245ed153dfcbeb204ba9181a89fa0a3b06 Mon Sep 17 00:00:00 2001 From: Vincent Orback Date: Mon, 16 Feb 2015 16:43:57 +0100 Subject: [PATCH 2/2] Added link in ToC. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6c55abc..7f59a5d 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ What I'm doing here is mostly collecting useful snippets from all over the inter - [Allow Cross-Domain Fonts](#allow-cross-domain-fonts) - [Auto UTF-8 Encode](#auto-utf-8-encode) - [Switch to Another PHP Version](#switch-to-another-php-version) + - [Serve WebP images](#serve-webp-images) ## Rewrite and Redirection Note: It is assumed that you have `mod_rewrite` installed and enabled.