• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue .htaccess rule ignored if file exists

yehudigt

Basic Pleskian
I'm trying to add webp support to mys ite but it seems that if my not webp file exists the .htaccess rule is being ignored.

System is
  • ‪CentOS Linux 7.7.1908 (Core)‬
  • Plesk Onyx 17.8.11 Aggiorna #73
Using Nginx + apache / static files served through nginx but not images

This is my .htaccess part involved

RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp]

Both thes files exists:

But according to the previous rule I should always seee the webp if my browser supports it.

The strange thing is that if I browse a rewrited url like this one:

Which is this physical url
https://www.magazzinirossi.it/img/p/6/7/9/0/7/67907-large_default.jpg

I see the webp image.

If I try the physical file directly it serves me the jpg instead of the webp although there is the rule in .htaccess.

Can anyone explain me how can this happen?

Thanks
 
In the default configuration the .jpg file is served by Nginx, because it is static content. Such requests never reach Apache, for that reason an .htaccess rule that is meant to rewrite an URL ending on .jpg will never be executed.
 
Thank you Peter,
but as I said static files are served through nginx but not images: all the extensions related to images have been removed from the textarea, so they should be passed to apache (acccording to Plesk documentation). Screenshot attached. The only way to make it work is to unselect the intelligent processing of static files, which means that although those fiels should be passed to apache they are not. Maybe this is a Plesk bug...
 

Attachments

  • Schermata 2020-04-07 alle 15.52.27.png
    Schermata 2020-04-07 alle 15.52.27.png
    206.8 KB · Views: 7
Back
Top