The following code will run files ending in .ext with php:
AddType application/x-httpd-php .ext
If WebP images are supported and an image with a .webp extension and the same name is found at the same place as the jpg/png image that is going to be served, then the WebP image is served instead.
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]
Remember that for most rules you must have the RewriteEngine on
rule in your .htaccess file!!!
Please remember to double check and verify any rules that you use. If you do not understand a rule please consult someone who does. Or if you are new, please take time to read this htaccess guide. We accept no responsibility for your use of these rules - use them at your own risk. Please get in touch if you want us to add a rule!