mod_rewrite: remove trailing slash (only one!)

前端 未结 5 646
面向向阳花
面向向阳花 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:01

    the following rule will match any URL ending in a slash and remove all slashes from the end of it:

    RewriteRule ^(.*)/+$ $1 [R=301,L]
    

    Note: The currently accepted answer only works for http not https but this one works for both.

提交回复
热议问题