I am transferring a site that was built on windows xampp to a server running ubuntu 24.04, apache 2.4.62, and php 7.4.33. Everything is working fine except php files containing spaces anywhere in the path are not found.
I have confirmed the file does actually exist by running
ls "/var/www/html/tempdir/test name.php"
which returns the file path.
I looked through the log files and am pretty sure I have nailed down where the hiccup is.
[core:trace5] [pid 14742:tid 14827] protocol.c(713): [client 127.0.0.1:35246] Request received from client: GET /tempdir/test%20name.php HTTP/1.1
[http:trace4] [pid 14742:tid 14827] http_request.c(435): [client 127.0.0.1:35246] Headers received from client:
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246] Host: localhost
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246] User-Agent: Wget/1.21.2
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246] Accept: */*
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246] Accept-Encoding: identity
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246] Connection: Keep-Alive
[authz_core:debug] [pid 14742:tid 14827] mod_authz_core.c(815): [client 127.0.0.1:35246] AH01626: authorization result of Require all granted: granted
[authz_core:debug] [pid 14742:tid 14827] mod_authz_core.c(815): [client 127.0.0.1:35246] AH01626: authorization result of <RequireAny>: granted
[core:trace3] [pid 14742:tid 14827] request.c(360): [client 127.0.0.1:35246] request authorized without authentication by access_checker_ex hook: /tempdir/test name.php
[proxy:trace2] [pid 14742:tid 14827] proxy_util.c(2457): [client 127.0.0.1:35246] *: fixup UDS from proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost/var/www/html/tempdir/test name.php: fcgi://localhost/var/www/html/tempdir/test name.php (/run/php/php7.4-fpm.sock)
[proxy_fcgi:trace1] [pid 14742:tid 14827] mod_proxy_fcgi.c(76): [client 127.0.0.1:35246] canonicalising URL //localhost/var/www/html/tempdir/test name.php
[proxy_fcgi:debug] [pid 14742:tid 14827] mod_proxy_fcgi.c(123): [client 127.0.0.1:35246] AH01060: set r->filename to proxy:fcgi://localhost/var/www/html/tempdir/test%20name.php
[proxy:trace2] [pid 14742:tid 14827] proxy_util.c(2625): [client 127.0.0.1:35246] *: using default reverse proxy worker for fcgi://localhost/var/www/html/tempdir/test%20name.php (no keepalive)
[proxy:debug] [pid 14742:tid 14827] mod_proxy.c(1465): [client 127.0.0.1:35246] AH01143: Running scheme fcgi handler (attempt 0)
[proxy_fcgi:debug] [pid 14742:tid 14827] mod_proxy_fcgi.c(1078): [client 127.0.0.1:35246] AH01076: url: fcgi://localhost/var/www/html/tempdir/test%20name.php proxyname: (null) proxyport: 0
[proxy_fcgi:debug] [pid 14742:tid 14827] mod_proxy_fcgi.c(1087): [client 127.0.0.1:35246] AH01078: serving URL fcgi://localhost/var/www/html/tempdir/test%20name.php
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(2797): AH00942: FCGI: has acquired connection for (*:80)
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3242): [client 127.0.0.1:35246] AH00944: connecting fcgi://localhost/var/www/html/tempdir/test%20name.php to localhost:8000
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3309): [client 127.0.0.1:35246] AH02545: fcgi: has determined UDS as /run/php/php7.4-fpm.sock (for localhost:8000)
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3450): [client 127.0.0.1:35246] AH00947: connecting /var/www/html/tempdir/test%20name.php to /run/php/php7.4-fpm.sock:0 (localhost:8000)
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3832): AH02823: FCGI: connection established with Unix domain socket /run/php/php7.4-fpm.sock (localhost:8000)
[proxy_fcgi:error] [pid 14742:tid 14827] [client 127.0.0.1:35246] AH01071: Got error 'Primary script unknown'
[proxy_fcgi:trace4] [pid 14742:tid 14827] util_script.c(572): [client 127.0.0.1:35246] Headers from script 'test%20name.php':
[proxy_fcgi:trace4] [pid 14742:tid 14827] util_script.c(575): [client 127.0.0.1:35246] Status: 404 Not Found
[proxy_fcgi:trace1] [pid 14742:tid 14827] util_script.c(654): [client 127.0.0.1:35246] Status line from script 'test%20name.php': 404 Not Found
[proxy_fcgi:trace4] [pid 14742:tid 14827] util_script.c(575): [client 127.0.0.1:35246] Content-type: text/html; charset=UTF-8
I am probably wrong, but I think the bug is when proxy_util.c(3450) connects to the socket it keeps the url tail formatted for tcp with the %20. So how to fix this? Restructuring the site is not an option.
Seems like this person was having the same trouble. https://stackoverflow.com/questions/26608035/fastcgi-url-cannot-contain-spacestext
2
Answers
Turns out that "The PHP Handler was using PHP-FPM, and the issue with the spaces appears to be a limitation therein. I was able to view the pages with spaces with PHP-FPM disabled. I have disabled PHP-FPM on your account on PHP 7.3."
It seems an issue starting with apache 2.4.59. See httpd bug 69203