我在我的htaccess文件中有以下代码:
# Force Trailing Slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/]+$ %{REQUEST_URI}/ [L,R=301]
当我访问www.mydomain.com/test时,似乎一切正常,它将其重定向到/test/。 但问题是当我访问 www.mydomain.com/test/another 时,它不会在 "another" 后面添加尾随斜杠。
有谁知道如何修改我的代码,使尾随斜杠在 URL 长度不同的情况下都能工作吗?
谢谢!
RewriteBase /
来解决这个问题。这使得重定向起作用非常顺畅! - Martie