rosell-dk / webp-express

Wordpress plugin for serving autogenerated WebP images instead of jpeg/png to browsers that supports WebP
GNU General Public License v3.0
221 stars 63 forks source link

Conflict with Redirect Pluigins #558

Open Hube2 opened 2 years ago

Hube2 commented 2 years ago

I'm having an issue with a conflict and plugins that do redirection.

In these plugins we do things like redirect old PDF files to new ones. The issue is that when the .htaccess file for this plugin is in place and the old pdf file does not exist then the server shows a 404 instead of redirecting. This 404 is also the server 404 and not the WP 404 page.

Is there a way to adjust the .htaccess in the uploads folder so that redirects of PDF files (or any file for that matter) so that the normal redirection and 404 handling happens when a requested file in the uploads folder does not exist?

Hube2 commented 2 years ago

I have .webp images stored in another folder, so I don't know if this will effect any other configuration.

However, in order to allow the default WP handling when a file does not exist in the uploads folder then the requests must be redirected to index.php in the site root.

Anyway, I have added this to the rules created by this plugin in the /wp-content/uploads/ folder

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]