📜  如何使用 .htaccess 从 url 中删除双斜杠 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:53.703000             🧑  作者: Mango

代码示例1

    RewriteBase /

    # rule 1: remove multiple leading slashes (directly after the TLD)
    RewriteCond %{THE_REQUEST} \s/{2,}
    RewriteRule (.*) $1 [R=301,L]

    # rule 2: remove multiple slashes in the requested path
    RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
    RewriteRule (.*) %1/%2 [R=301,L]