使用htaccess从特定URL中删除尾部斜杠

时间:2015-01-27 17:56:09

标签: .htaccess mod-rewrite redirect

如何从特定网址重定向尾部斜杠

例如:

http://blabla.com/builders/anynumber1/anynumber2/anynumber3/London(any country)/

http://blabla.com/builders/anynumber1/anynumber2/anynumber3/London(any country)

1 个答案:

答案 0 :(得分:0)

怎么样:

RedirectMatch 301 ^/([^/]+/[0-9]+/[0-9]+/[0-9]+/[^/]+)/$ /$1

RewriteEngine On
RewriteRule ^([^/]+/[0-9]+/[0-9]+/[0-9]+/[^/]+)/$ /$1 [L,R=301]

编辑: 您需要使用mod_rewrite:

RewriteRule ^([^/]+/[0-9]+/[0-9]+/[0-9]+/[^/]+)/.+$ - [L,R=404]