Apache htaccess重定向尾部斜杠

Apache htaccess重定向尾部斜杠,apache,.htaccess,codeigniter,redirect,Apache,.htaccess,Codeigniter,Redirect,我正在尝试重定向url,所以如果url要重定向到 以下是.htaccess文件的内容 RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|images|assets|stylesheets|scripts|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI}

我正在尝试重定向url,所以如果url要重定向到

以下是.htaccess文件的内容

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|assets|stylesheets|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
问题是重定向不起作用。当我输入时,响应是200。 我想要的是301重定向到url,并在末尾加上/
我做错了什么?

这应该可以

RewriteEngine on
RewriteBase /

# if it's an existing folder or file, do nothing
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

# if no trailing slash then add it
RewriteRule ^(.+)([^/])$ $1$2/ [L,R=301]

# internally rewrite url to index.php controller
RewriteRule ^(.*)$ index.php/$1 [L]

[L,R=301]
应该是
[R=301]
我改为[R=301],但没有效果