大网数据广告活动
网站运营与故障问答

AH10411: Rewritten query string contains control characters or spaces

· 52CE 我爱测

How to reproduce the error: -- A space in my URL will trigger the error. Observation of the error: -- It seems to happen suddenly since around 3/10. ---- I did not upgrade my Apache version, but it seems like the -1ubuntu4.27 pac…

问题原文

原帖链接 · Chi · CC BY-SA 4.0

How to reproduce the error:
-- A space in my URL will trigger the error.

Observation of the error:
-- It seems to happen suddenly since around 3/10.
---- I did not upgrade my Apache version, but it seems like the -1ubuntu4.27 package was being auto-installed (There are related messages on the /var/log/dpkg.log.).
-- On browser: 403 Forbidden error.
-- On Apache error log: it gets the AH10411: Rewritten query string contains control characters or spaces error.

Potential solution:
I found two references, user @MrWhite suggested using the B flag on RewriteRule. It does work for my server.

My question:
-- Precisely, is it that particular package causing the error?
-- Does this problem only happen to RewriteRule?
-- Is there a universal fix? I mean if I have multiple applications, instead of changing each of their RewriteRule, is it possible to make correction one time and the fix can be applied to the entire server?

Related reference:
-- https://stackoverflow.com/questions/75684314/ah10411-error-managing-spaces-and-20-in-apache-mod-rewrite
-- RewriteRule started returning 403 Forbidden error

社区高分解答

原帖链接 · Alexis Wilke · CC BY-SA 4.0

As pointed out by Rohit Gupta in a comment, there was a change to Apache2 outlined in this git pull request, I just had to change my RewriteRules to include the B and BNP flags.

For example:

RewriteRule ^(.*)$ index.php?q=$1 "[L,QSA,B= ?,BNP]"

The old RewriteRule did not include that B and BNP entries. The BNP may not be necessary for your service. It makes sure to use %20 instead of + for the space (i.e. NP as No Plus).

Make sure you change all the RewriteRule in this way.

IMPORTANT NOTE:

The quotation is important in that case because a space delimits parameters by default. In other words:

[L,QSA,B= ?,BNP]

would be viewed as

[L,QSA,B=

and

?,BNP]

and obviously Apache2 would fail to load that.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2023-03-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。