lundi 7 septembre 2020

Laravel 5.2 Display webp images if browser supports using .htaccess

I have updated the image upload in our server that saves both original image and its webp version. I want to use the webp image if the client browser supports it. Now, I have added this script in my htaccess file but it's still not working.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
RewriteCond %{REQUEST_FILENAME}\.webp -f
RewriteCond %{QUERY_STRING} !type=original
RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1,L]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>

This is found in public/.htaccess. Is this the right way to implement in Laravel 5.2?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire