本文介绍了如果在htaccess中获取301,则将URL中的特殊字符重定向到其他字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

规则:将包含%252C + 的所有URL重定向到,-,并重定向 + -,仅当 + 带有%252C +

Rule: Redirecting all URLs that contains %252C+ to ,- and redirecting + to - only if the + comes with %252C+.

e.g1: http://www.example.com/FortWorth%252C+TX/
到: http://www.example.com/FortWorth,-TX/

e.g2: http://www.example.com/Fort+Worth%252C+TX/
到: http://www.example.com/Fort-Worth,-TX/

e.g3: http://www.example.com/Fort+Worth/
到: http://www.example.com/Fort+Worth/
(不应重定向该地址)

e.g3: http://www.example.com/Fort+Worth/ to: http://www.example.com/Fort+Worth/ (Should not redirect this one)

注意:请记住,您的代码不仅应针对上述URL,而且应针对具有

Note: Please remember your code should not be only for the above URL but for all URLs with the above rule.

推荐答案

感谢Sumurai8为您提供的解决方案,但需要像下面的代码一样进行修改:

Thanks Sumurai8 , for your solution but it needs to be modified like This code :

RewriteEngine On

RewriteRule ^([^+]+)\+(.+)%2C+\+(.*)$ /$1-$2,-$3 [R,L]
RewriteRule ^([^+]+)%2C+\+(.*)$ /$1,-$2 [R,L]

这篇关于如果在htaccess中获取301,则将URL中的特殊字符重定向到其他字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:36