【问题标题】:How to add slash at the end of url in htaccess?如何在htaccess中的url末尾添加斜杠?
【发布时间】:2019-06-07 14:24:47
【问题描述】:

RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

当我使用它在末尾添加斜杠时,它会像 example.com//

一样重定向

但我想重定向我的网址

 www.example.com 

到

 www.example.com/

谁能建议我如何做到这一点?

【问题讨论】:

    标签: .htaccess url mod-rewrite redirect trailing-slash


    【解决方案1】:

    【讨论】:

    • RewriteBase / RewriteCond %{index.php} !-f RewriteCond %{HTTP_HOST} !index.php RewriteCond %{HTTP_HOST} !(.*)/$ RewriteRule ^[^/]*$ http://%{HTTP_HOST}/$1/ [L,R=301] 当我使用这个时,我在 url 的末尾有两个斜杠,但我只需要一个斜杠,你能建议我吗?
    猜你喜欢
    • 1970-01-01
    • 2021-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-23
    • 2018-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多