Why do you want to remove the trailing slash?
It’s common for URLs with a trailing slash to indicate a directory, and those without a trailing slash to denote a file. URL’s without a trailing slash or an extension just don’t look right.
In the case of tidy links the addresses end up at the same location. For example The Best Mac Website Builder - RapidWeaver Classic and The Best Mac Website Builder - RapidWeaver Classic will both go to the same URL. The Web server knows that even a technically incomplete address (a URL that ends with a folder name only) needs the trailing slash. Click on The Best Mac Website Builder - RapidWeaver Classic and then look at the address bar. The trailing slash has been added.
Stackoverflow is probably the largest technical forum on the internet without a link to the post you are using it’s hard for anyone else to see what the author(s) might be talking about.
I think this is the post you are talking about:
php - Htaccess: add/remove trailing slash from URL - Stack Overflow
Both solutions offered above do work. They both will remove the trailing slash from a URL. The problem is when you use tidy links you aren’t providing a complete URI, you aren’t giving the filename portion of the URL. So when either of the above options executes, they will remove the trailing slash.
So in my example URL above
https://www.realmacsoftware.com/rapidweaver/
Will become:
https://www.realmacsoftware.com/rapidweaver
Next, Apache (or Nginx) will then get a URL that doesn’t end with a /
indicating it’s a directory (folder) and it’s not a file name. It could issue a 404 (not found) but it also knows that it has a directory with that name. So a 301 redirect will get issued. Back to:
https://www.realmacsoftware.com/rapidweaver/
Now the webserver has a directory name, It knows that if it has a request for a directory without a file name to look for files with certain names that are in that directory.
A typical Apache DirectoryIndex Directive:
DirectoryIndex index.html index.php index.cgi
The Webserver will then look from left to right for a file in that directory until it finds one that matches the name or it will then issue a 404.
So both solutions given above do strip off the trailing slash. You can paste either one of them into https://htaccess.madewithlove.be/ an excellent htaccess file tester. (the first one you’ll need to remove the comments as #
isn’t at the beginning of a line). And you can see that the Output URL is returned without the trailing /
.
But as you have discovered the webserver adds it back in.