• Resolved omris83

    (@omris83)


    I’m with SiteGround (Apache servers) and cant get the webp htaccess mod redirect to work. Siteground have said:

    Thank you for your patience.

    The files are indeed loaded via .jpg extension but internally they are using the .webp format which you set. You can verify this from the response headers of the request.

    https://screencast.com/t/SrjdTkFod

    This is normal behavior as your mod_rewrite code in the .htaccess file does not include redirect (through the “R” flag) and the images remain with the same URL. If you would like to have the same redirected, you should consider updating your .htaccess code.

    Does anyone know how to update the htaccess so it redirects through the R flag?

Viewing 1 replies (of 1 total)
  • Plugin Author ShortPixel

    (@shortpixel)

    Thanks for reaching out!
    The fact that the WebP image is served with the original extension (.jpg for example) is intended, because a redirect for each image would impact the performance of the page (doing another round trip to the web server for that image). Could you please tell me what would be the reason/use-case needing this redirect, in the first place? If you still need to do the 302 redirect, you should use:

    RewriteRule (.+)\.(?:jpe?g|png)$ %1.webp [NC,T=image/webp,E=webp,R,L]

    This worked on my test environment. Please also note that you’re using an old version of the ShortPixel’s .htaccess code, you can take the newer version from the plugin in res/img. Then you should also remove the section marks # BEGIN/END ShortPixelWebp together with the option in Advanced settings, because otherwise the plugin will rewrite the .htaccess section if deactivated and reactivated.

Viewing 1 replies (of 1 total)

The topic ‘htaccess redirect doesnt work. Need help with modifying code..’ is closed to new replies.