I've found this post (https://stackoverflow.com/a/21417551/2722571) which works to add a trailing slash using the code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R] # <- for test, for prod use [L,R=301]
However, it breaks when submitting a contact form which requires a specific URL without a trailing slash.
/wp-json/contact-form-7/v1/contact-forms/1593/feedback
All forms use the same pattern up to the form id, i.e. this part is always the same:
/wp-json/contact-form-7/v1/contact-forms/
How do I amend the rule to ignore the above pattern URL whilst still enforcing the rest of the rule?
I've tried a few variations of the above rule like this, but it doesn't work and it either ignores the whole rule or throws an error. One example of what I've tried is below:
RewriteCond %{REQUEST_URI}!^/wp-json -d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R]
PS. I am not a htaccess expert so not sure if the above rule is valid or what its doing exactly.