Last Updated: February 25, 2016
·
987
· moiseevigor

Allow optional trailing slash when using optional parameter

I found this way to achive this with Apache mod_rewrite enabled. Snippet of .htaccess

RewriteEngine On

# remove trailing slash
RewriteCond %{HTTPS} off
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^(.+[^/])/$ https://%{HTTP_HOST}/$1 [R=301,L]