Redirect 301, served under Apache 2.4, fails in Webkit browsers such as Safari on macOS, Google Chrome on iOS (iPad), and so on. This terrible behaviour affect many situations in which redirection is needed.
For example, when my mediawiki redirects from
index.php?title=特別:ログイン, Safari says
NSPOSIXErrorDomain: 100 and shows nothing other than the error message. Of course, there are no problems if I try redirection on other OS and browsers. By
curling the same URL, I find out that the redirection response contains extra packets with the following message:
Excess found in a non pipelined read: excess = 20 url = /index.php (zero-length body)
Content-Length is 0. This is caused by compressing empty data in
include/OutputHandler.php. If we do not perform the gzip compression in between
ob_end_flush, extra bytes do not appear, so redirection goes without any problems as expected. For this, I have confirmed that setting
$wgDisableOutputCompression = false or commenting out the corresponding line in
OutputHandler.php resolves the redirection error in Webkit browsers.
- Server version: Apache/2.4.6 (CentOS)
- Safari 14.0 (15610.1.28.1.9, 15610) / MacOS Catalina 10.15.7
I also tried other environments as follows:
- PHP 7.4.12 with
php -S localhost:9000on my local PC. No extra bytes. No redirection errors.
- PHP 7.4.4 served under nginx 1.16.1. No extra bytes. No redirection errors.
- Checking extra bytes in response by
curl -i -v --compressed --http1.1 'http:// host : port /index.php?title=Special:Login'
So the problem (perhaps?) seems like specific to the combination with Apache 2.4. Note that some blog authors say that, when served by Apache 2.4, the error
NSPOSIXErrorDomain: 100 can be resolved by
Header unset Upgrade, but this did not work well for me. I think HTTP/2 Upgrade header has nothing to do with the redirection error in my situation.