本文介绍了htaccess的德codeS%2B和+都进入太空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法能够使用mod_rewrite时以任何方式传递一个+

手动添加这到查询字符串 _tags = C%2B%2B +堆栈+溢,被正确地转换为 C ++堆栈溢出

但使用mod_rewrite时(使用或不使用[NE]标志)

 重写规则^标签/([\\ w _ \\  -  \\ + \\%] +)?$ tags.php _tags = $ 1 [QSA,L]

然后,它会转换为 C堆栈溢出(注意3个空格)。使用[B]国旗让我ç+++堆栈溢出+ 代替。

目标是,无论?_标记= C%2B%2B +堆栈+溢 /标签/ C%2B%2B +堆栈+溢

应该导致 C ++堆栈溢出

我使用的空间作为分隔符分裂的标记。

  $标签= array_unique(爆炸(,$ _REQUEST [_标签]))


解决方案

The URL standard says that /tags/C%2B%2B+Stack+Overflow is semantically equivalent to C+++Stack+Overflow. Pluses are not specified to represent spaces in path components; the [B] behaviour is correct.

Path and query components are deliberately different. If you want to include the same escaped content in both you should avoid the difference by using the unambiguous %20 in preference to +.

You could try to pick up the difference between + and %2B by looking at the raw $_SERVER[REQUEST_URI] and picking it apart manually instead of using the standards-compliant parsers PHP gives you. But it's not likely a good idea.

这篇关于htaccess的德codeS%2B和+都进入太空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 18:59