htaccess的删除不需要的字符从URL不需要、字符、htaccess、URL

2023-09-02 20:34:24 作者:男友难有

我们的电流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

感谢您的帮助。

解决方案 怎么让IIS支持PHP的.htaccess文件

这添加到您的规则上:

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

您可以使用> 因为URI匹配时得到德$ C $光盘重写规则

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.