问题原文
原帖链接 · 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
