htaccess的删除不需要的字符从URL [英] Removing unwanted characters from URL in htaccess

查看:138
本文介绍了htaccess的删除不需要的字符从URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的电流htaccess的设置正确转换的网址是这样的:site.com/page.php?sid=Friend到site.com/Friend

然而,由于一个不相关的监督,我们几乎所有的网址的双指数为site.com/Friend>由于大于号是一个特殊的字符不叫page.php因此>需要被剥离出来htaccess的,不能被上page.php完成。使事情复杂化的是,他们正在建立索引的方式是:site.com/Friend%3E这可能还需要被剥离出来

我们希望的是有另一个指令,查找的结局>(或%3E),剥离其关闭,然后重定向到变量的存在,而不认为,结束>从本质上说,这样site.com/Friend> (或site.com/Friend%3E)仍然指向site.com/Friend

感谢您的帮助。

解决方案

这添加到您的规则上:

 重写规则^ /&GT?(*); $ / $ 1 [L,R = 301]
 

您可以使用&GT; 因为URI匹配时得到德$ C $光盘重写规则 <。 / P>

Our current htaccess setup correctly converts urls like this: site.com/page.php?sid=Friend to site.com/Friend

However, due to an unrelated oversight, we had almost all of our URLs double-indexed as site.com/Friend> Because the greater than sign is a special character it doesn't call page.php so the > needs to be stripped out in htaccess and can't be done on page.php. Compounding matters is that the way they're indexed is as: site.com/Friend%3E which also might need to be stripped out.

What we would like is to have another directive that looks for an ending of > (or %3E), strips it off, then redirects to the variable that's there without that ending > In essence so that site.com/Friend> (or site.com/Friend%3E) still points to site.com/Friend

Thank you for your help.

解决方案

Add this to the top of your rules:

RewriteRule ^/?(.*)>$ /$1 [L,R=301]

You can use > because the URI gets decoded when matching in a RewriteRule.

这篇关于htaccess的删除不需要的字符从URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆