• Resolved peterjrees

    (@peterjrees)


    Hi there,

    I was having some trouble getting my site to serve WebP converted images and realised the # BEGIN W3TC WEBP section was missing from my .htaccess file. After manually adding the below to .htaccess it seems to be working perfectly:

    # BEGIN W3TC WEBP
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_ACCEPT} image/webp
        RewriteCond %{REQUEST_FILENAME} (.+)\.(jpe?g|png|gif)$
        RewriteCond %1\.webp -f
        RewriteCond %{QUERY_STRING} !type=original
        RewriteRule (.+)\.(jpe?g|png|gif)$ $1.webp [NC,T=image/webp,E=webp,L]
    </IfModule>
    <IfModule mod_headers.c>
        <FilesMatch "\.(jpe?g|png|gif)$">
            Header append Vary Accept
        </FilesMatch>
    </IfModule>
    AddType image/webp .webp
    # END W3TC WEBP

    Strangely, the # BEGIN W3TC Page Cache core rules were automatically generated but not the above rules. Just wondering if I’m missing something here – is there a setting that generates the WebP rules automatically? And is there a risk of the manually added WebP rules being overwritten when I update the plugin settings?

    Cheers,
    Peter

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @peterjrees

    Thank you for reaching out and I am happy to help!

    The Enable WebP Converter Extension, when enabled, adds the rules for webp conversion in .htaccess.
    The rules are added according to the settings currently enabled in the W3 Total cache. All the available rules you can check in the Performance>Install tab.
    In some cases, depending on the permissions, the rules may not be added or may be added in the wrong section of the .htaccess.

    To answer your question, if those rules are W3 Total Cache rules, those will no be removed if the setting that is adding these is not disabled.

    I hope it helps!

    Thanks!

    Thread Starter peterjrees

    (@peterjrees)

    Hi @vmarko and thanks for your reply!

    I had a look in the Performance > Install tab and the WebP rules are being added to litespeed.conf instead of .htaccess for some reason.

    Any idea why this might be happening?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @peterjrees

    Thank you for your feedback.
    Ah, so it’s a litespeed server. In some environments, as it’s in your case, the detection of the configuration file may cause that the rules are written elswhere.

    We’ll investigate more on how to approach these cases in the future.

    Thanks!

    Thread Starter peterjrees

    (@peterjrees)

    No problem @vmarko and thanks for the clarification – I’ll just stick with manually adding it to .htaccess for now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WebP rules not writing to .htaccess’ is closed to new replies.