Answers for "htaccess remove trailing slash"

PHP
1

bash remove trailing slash

VALUE=/looks/like/a/path///

TRIMMED=$(echo $VALUE | sed 's:/*$::')

echo $VALUE $TRIMMED
Posted by: Guest on October-17-2021
0

Remove .php extension & Remove trailing slash

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
RewriteCond %{THE_REQUEST} /([^.]+).php [NC]
RewriteRule ^ /%1 [R=301,NC,L,R]
RewriteRule ^(.*)/(?.*)?$ $1$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
Posted by: Guest on June-30-2021
0

how to remove double slash from the url with .htaccess

<IfModule mod_rewrite.c>
    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]
</IfModule>
Posted by: Guest on September-16-2021

Code answers related to "htaccess remove trailing slash"

Browse Popular Code Answers by Language