.htaccess仅针对特定目录重写条件结尾斜杠

我有这个伟大的规则,并为我的网站上的每个目录添加一个尾随斜杠。 我怎样才能添加尾部斜线只有某些目录这样/ courses /? 我不希望每个目录/path都有一个结尾的斜杠。

RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] 

 RewriteCond %{REQUEST_URI} ^/(courses|foo|bar)$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] 

应该在courses地方工作, foobar是你想添加尾部斜线的目录。

认为这将工作:

 <Files .htaccess> order allow,deny deny from all </Files> Options All -Indexes IndexIgnore * # Don't add trailing slash for /include/ RewriteEngine On RewriteCond %{REQUEST_URI} ^/include/$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 # Respond to /include/ with 404 instead of 403 RedirectMatch 404 ^/include(/?|/.*)$