Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Created April 26, 2023 12:17
Show Gist options
  • Save gmmedia/1c684cf78c079bba486817e950df141f to your computer and use it in GitHub Desktop.
Save gmmedia/1c684cf78c079bba486817e950df141f to your computer and use it in GitHub Desktop.
WordPress: Force add trailing slash
# Force trailing slash
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !^/wp-json/
RewriteCond %{REQUEST_URI} !^/gravatars/
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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment