I think the problem is that after Apache overwrites / news into the / subdirectory / news, it finds itself with a request corresponding to a directory in the file system that does NOT end with a trailing slash. Therefore, it issues a redirect to the new URL, including the trailing slash.
The thing is, in fact, we want the handle to be added to preserve the canonical URL (otherwise we end up with / news and / news / leading to the same place - not good for relative links, SEO, etc.), just not quite the way Apache does it. Therefore, we must do it ourselves by adding the following:
RewriteCond %{REQUEST_URI} ^/subdirectory/.*[^/]$ RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^subdirectory/(.*)$ /$1/ [L,R=301]
The conditions of this rule will correspond to any requests starting with a "subdirectory", DO matches the directory on fielsysem, but does not end with a slash. (e.g. '/ subdirectory / news'). The rewriting program then provides a constant redirect to the same path, but ends with a slash and disables "subdiretcory" (for example, "/ news / ').
The client then issues a request to '/ news /', apache rewrites this to / subdirectory / news / and will not issue a redirect because it ends with a slash.
Quickly checked it out and seemed to do the trick.
source share