mod_rewrite: remove trailing slash (only one!)

前端 未结 5 651
面向向阳花
面向向阳花 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 09:58

    Here is a mod-alias based solution to remove trailing slash from urls :

    RedirectMatch ^/(.*?)/$ /$1
    

    You can use the above Redirect in your htaccess or server.config file.

    This will redirect /uri/ to */uri** .

提交回复
热议问题