WP Rocket Trailing Slash Helper Plugin

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

See WP Rocket & Redirects for context.


I've uploaded the ZIP file to somewhere and installed the plugin through something like

wp plugin install /var/www/media.example.com/plugins/wp-rocket-htaccess-trailing-slash.zip --activate

Probably, I didn't need to upload it to an own location: I could probably equally well use the original WP Rocket location.

How it works

  • It seems to add a section to the WP Rocket section of the root .htaccess file of a site.
  • When Apache doesn't have sufficient rights to make these changes to .htaccess, no warnings or errors are given
  • There are no controls to manage this plugin. I suspect it does it stuff when activated through wp-admin. I have the impression that it doesn't work when activated through WP-CLI
  • All it does, is add the following section to the top of the WP Rocket section of .htaccess (for my specific case, using SSL & Apache)
  • Doesn't this conflict with the other WP Rocket Rewrite section that replaces pages with their cached version? I don't know and I'm not going to figure it out now (2023.11)

The section that it adds to the top of the WP Rocket portion of the root .htaccess file (for a specific case: Apache + SSL):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !^/wp-json/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|xml|txt|js|php|scss|webp|mp3|avi|wav|mp4|mov|pdf|html|htm|xst)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]

Conclusion: This 'helper plugin' is fine, but I would probably prefer to do this directly in .htaccess without the need for a plugin. I think that for most of the sites that I manage, that I'm beyond the stage that plugins are allowed to make their own changes to this file.

See also