'Htaccess - trailing slash redirection disables post changes

I am trying to make all URLS end with trailing slash on my wordpress site. I tried both these rules in htaccess:

#Trailing slash
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

#Trailing slash
RewriteEngine On
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

The redirect works fine, but it breaks my admin in a way that any changes made to Wordpress posts are not being saved.

I also tried to add one more line but without any changes:

#Trailing slash
RewriteEngine On
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

#Trailing slash
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

Do you have any tip on how to fix this?

Thank you Pavel



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source