mod_rewrite: remove trailing slash (only one!)

前端 未结 5 645
面向向阳花
面向向阳花 2020-11-28 09:38

I use mod_rewrite/.htaccess for pretty URLs.

I\'m using this condition/rule to eliminate trailing slashes (or rather: rewrite to the non-trailing-slash-URL, by a 301

5条回答
  •  一整个雨季
    2020-11-28 10:05

    change the rewrite rule to:

    RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]
    

    in English: match the start of the string, one or more anything, NOT a slash, a slash, the end.

提交回复
热议问题