Where to place custom code in htaccess for webp display

Home Forums BulletProof Security Pro Where to place custom code in htaccess for webp display

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42037
    protection
    Participant

    Hello –

    The theme I’m using has the ability to display images in webp format as opposed to jpeg or png. Since I don’t want the theme to write directly to the .htaccess file, where would I place the custom code within the .htaccess code editor? Below is the code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    # serves a .webp image instead of jpg/png
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_FILENAME} ^(.+)\.(jpe?g|jpg|png)$
    RewriteCond %1\.webp -f
    RewriteRule ^(.+)\.(jpe?g|jpg|png)$ $1.webp [T=image/webp,E=accept:1]
    </IfModule>
    <IfModule mod_headers.c>
    Header append Vary Accept env=REQUEST_image
    </IfModule>
    <IfModule mod_mime.c>
    AddType image/webp .webp
    </IfModule>
    
    #42038
    AITpro Admin
    Keymaster

    The best place for that code would be in this Root Custom Code text box: 1. CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE, click the Save Root Custom Code button and activate Root Folder BulletProof Mode again.

    #42039
    protection
    Participant

    Perfect, thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.