简体   繁体   中英

Removal of multiple trailing slashes after URL

I'm using Apache24, and I recently noticed an issue with the multiple trailing slashes after the URL (I'm not referring to the http:// slashes).

Here's my URL

website.com//user/profile:view

Which is not displaying the correct page, obviously.

Here's my .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>

I've tried dozens of other "fixes" but none of them have seemed to work.

How could I fix this? Thanks.

To remove multiple slashes use this rule before your existing rule below RewriteEngine line:

RewriteCond %{THE_REQUEST} \s/+(.*?)/+(/\S*) [NC]
RewriteRule ^ %1%2 [R=302,L,NE]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM