Causes
This error typically occurs when the web server cannot find the specified PHP file or script. Possible causes include:
open_basedirrestriction: Check the.user.inifile in the website's root directory to confirm that theopen_basedirconfiguration includes the paths to all required directories.Incorrect rewrite rule configuration: Check the rewrite (pseudo-static) rules in the website's configuration file to ensure requests are not misdirected to a non-existent PHP file.
Incorrect PHP handler configuration: Check the PHP runtime mode settings in the website's configuration file to ensure the web server passes requests to the PHP interpreter.
Solutions
Linux
The following steps use Alibaba Cloud Linux 3 as an example.
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance. Click Connect and select Workbench. Follow the prompts on the page to log on to the terminal.
Check for
open_basedirrestriction.In the website directory, check for the hidden
.user.iniconfiguration file.sudo ls -la <website_directory>For example, if the website directory is
/www/wwwroot/www.abc.com/, runsudo ls -la /www/wwwroot/www.abc.com/.If the file exists, continue to the next step.
If the file does not exist, this restriction does not apply. Proceed to modify the configuration file.
Check the
open_basedirsettings.In the
.user.inifile, find the line that starts withopen_basedir. Check if the directory list includes the full root path of the target website.For example, if the website directory is
/www/wwwroot/www.abc.combut the.user.inifile containsopen_basedir=/www/wwwroot/www.test.com/:/tmp/, add the missing path.
Modify the configuration file.
Apache
Check and correct the
.htaccessfile.Go to the website's root directory and check for the
.htaccessfile. If it exists, ensure theRewriteRuleline is configured as follows.This rule ensures that requests are redirected to
index.php.RewriteRule ^(.*)$ /index.php?/$1 [L]Restart the Apache service.
sudo systemctl restart httpd
Nginx
Check and correct the
php.iniconfiguration.Edit the
/etc/php.inifile and set thecgi.fix_pathinfoparameter to1.The default value is
1. This setting lets the PHP interpreter find the correct file path, which improves compatibility.Check and correct the
fastcgi.confconfiguration.Edit the
/etc/nginx/fastcgi.conffile and ensure that it contains the following configuration. This configuration ensures the web server passes requests to the PHP interpreter.fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $document_root;Restart the Nginx service.
sudo systemctl restart nginx
Verify website access.
After completing these steps, refresh website to confirm the issue is resolved.
Windows
The following steps use Windows Server 2022 with Internet Information Services (IIS) as an example.
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance, click Connect, and select Workbench. Set the connection method to Terminal, enter the username and password, and then log on to the graphical terminal page.
Check for
open_basedirrestrictions.Check if the
.user.inihidden configuration file exists in the website directory.In the File Explorer menu, click View and select the Hidden Items checkbox.
If the file exists, continue to the next step.
If the file does not exist, this restriction does not apply. Proceed to troubleshoot the IIS PHP handler configuration.
Check the
open_basedirsettings.In the
.user.inifile, find the line that starts withopen_basedir. Check if the directory list includes the full root path of the target website.For example, if the website directory is
C:\inetpub\wwwroot\mywebsitebut the.user.inifile containsopen_basedir = "C:\inetpub\wwwroot\abc", the path is incorrect and must be corrected.
Check the PHP handler configuration for IIS.
Edit the
php.inifile.Comment out
doc_root.Add a semicolon (
;) at the beginning of the line containing thedoc_rootfield to comment it out.
Modify
cgi.force_redirect.Remove the semicolon (
;) from the beginning of the line containincgi.force_redirect = 1and change its value to `0`. This change disables a security check, allowing PHP to run with IIS.
Restart the IIS service.
Press
Win+R, typePowerShell, and pressEnter. In the PowerShell window, run the following command to restart the IIS service.iisreset /noforce
Verify website access.
After completing these steps, revisit your website to confirm the issue is resolved.