Bug 13991 - httpd doesn't serve index.php with 1.32
Summary: httpd doesn't serve index.php with 1.32
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.32.x
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-09 18:04 UTC by KS
Modified: 2023-03-09 21:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description KS 2021-07-09 18:04:14 UTC
I have upgraded a system that was previously running 1.29.2 to busybox 1.32.0. The system is running httpd and the index file name is set to index.php, with the php interpreter configured for all *.php file.

Since the update, it's not possible to access any php files without explicitly writing "index.php" in the URL. Example:

http://my-ip/index.php works on both systems
http://my-ip/ only works on 1.29.2

I get a 404 error and the following log:

[::ffff:192.168.10.5]:60708: can't execute '': No such file or directory
[::ffff:192.168.10.5]:60708: response:404

My httpd.conf file is:
=============

*.php:/usr/bin/aarch64-linux-php-cgi
I:index.php
h:/var/www

# Mime types
.pdf:application/pdf
.yaml:text/yaml
.js:text/javascript
Comment 1 KS 2021-07-09 19:16:27 UTC
I found a work-around for this issue. I created a cgi-bin/index.cgi file with the following content:
------

#!/bin/bash

php_name="/var/www/$REQUEST_URI/index.php"

if [[ -f $php_name ]]; then
        export SCRIPT_FILENAME=$php_name
        cd `dirname $php_name`
pwd
        aarch64-linux-php-cgi
else
        exit 1
fi
Comment 2 Vex Mage 2023-03-09 21:58:01 UTC
I'm having this problem too on version 1.34.1, although I'm using ph7 not php. Here's my script I wrote to workaround the issue. It, hopefully, preserves any query string and redirects sub directories. I'm certain there are bugs.


/etc/httpd.conf
H:/var/www
I:index.php
A:*
*.php:/usr/bin/ph7


/var/www/cgi-bin/index.cgi:
#!/bin/sh
REDIRECT_URI=`echo ${REQUEST_URI} | awk -F? '{ print $1 }'`
REDIRECT_QUERY=`echo ${REQUEST_URI} | awk -F? '{ print $2 }'`

if [ -e $REDIRECT_QUERY ] ; then
  REDIRECT_PATH=${REDIRECT_URI}index.php
else
  REDIRECT_PATH=${REDIRECT_URI}index.php?${REDIRECT_QUERY}
fi

echo "Status: 307 Temporary Redirect"
echo "Location: ${REDIRECT_PATH}"
echo ""