如何从URL使用htaccess的删除// [英] How to remove // from URL using htaccess
本文介绍了如何从URL使用htaccess的删除//的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从URL中删除/,如果他们出现两次或三次。
像:
How to remove / from URL if they appear twice or thrice.
Like:
www.site.com/mauritius_holiday_rentals/search//2/Pool-Villa
应成为
www.site.com/mauritius_holiday_rentals/search/2/Pool-Villa
和
www.site.com/mauritius_holiday_rentals/search ///海滩别墅
www.site.com/mauritius_holiday_rentals/search///Beach-Villa
应成为
www.site.com/mauritius_holiday_rentals/search/Beach-Villa
www.site.com/mauritius_holiday_rentals/search/Beach-Villa
推荐答案
您可以使用RedirectMatch指令与正则表达式,所以如果一个额外的前页斜线加意外的URL,那么你有一个机会,使其可选或永久删除它从URL。
You can use RedirectMatch directive With Regex, so If an additional forword slash was added accidently to the url ,then you have a chance to make it optional or permanently delete it from the url.
RedirectMatch 301 ^/mauritius_holiday_rentals/search//?/?/2/(.*)$ /mauritius_holiday_rentals/search/2/$1
RedirectMatch 301 ^/mauritius_holiday_rentals/search//?/?/(.*)$ /mauritius_holiday_rentals/search/$1
这篇关于如何从URL使用htaccess的删除//的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文