将所有带有尾随的页面重定向到 URL 而不尾随当根目录的一部分是文件夹时

Redirect all pages with trailing to the URL without trailing WHEN part of the root is a folder

我已经尝试了所有找到的代码,在输入时将它们重定向到根目录 URL,但它仅适用于 URL 而不是文件夹,即 [=20] =] /mylink.html 我有文件夹 "mylink" 并在其中放置了我的文章,因此我尝试访问该文章并且它表现良好,但是每当我单击与包含子页面的文件,它会出现 401 或 500 错误!

提前致谢!

这是我的代码:

# redirect trailing at the end
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|ico|webp|jpeg|css|js)$ [NC]
RewriteRule ^(.*)$ https://example.com// [L,R=301]

发布问题后答案闪过我...如果这对其他人有帮助,只需为 "doubles" 文件夹名称的每个文件添加此行:

RewriteRule ^mylink\/$ "https\:\/\/www\.website\-whatever\.com\/mylink" [R=301,L]

干杯☺