简体   繁体   中英

Nginx all pages Shows 404 error except homepage

I use CentOS 7, I tried to enable the rewrite module but the problem showing homepage on every page.

I get this error from error_log

2021/03/07 22:42:20 [error] 8630#0: *127 FastCGI sent in stderr: "PHP message: PHP Deprecated:  The each() function is deprecated. This message will be suppressed on further calls in /www/wwwroot/example.com/include/security.php on line 4" while reading response header from upstream, client: 108.162.245.205, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi-74.sock:", host: "example.com", referrer: "https://example.com/test-1"

I also try to remove the line 4 as i saw in the error log but the issue still showing up

<?php
defined('_VALID') or die('Restricted Access!');

if ( get_magic_quotes_gpc() ) {
    $in = array(&$_GET, &$_POST, &$_COOKIE);
    while ( list($k,$v) = each($in) ) {
        foreach ($v as $key => $val) {
            if (!is_array($val)) {
                $in[$k][$key] = stripslashes($val);
                continue;
            }
            $in[] =& $in[$k][$key];
        }
    }
    unset($in);
}

function disableRegisterGlobals()
{
    if( (bool)@ini_get('register_globals') ) {
        $noUnset    = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');                                                                   
        $input      = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
    
        foreach ($input as $k => $v) {
            if (!in_array($k, $noUnset) && isset($GLOBALS[$k])) {
                unset($GLOBALS[$k]);
            }
        }
    }
}
?>

btw I don't have a good knowledge about php or nginx

You are using legacy code, remove the old function as it always returns false, its meaning is unclear

if ( get_magic_quotes_gpc() ) {
    $in = array(&$_GET, &$_POST, &$_COOKIE);
    while ( list($k,$v) = each($in) ) {
        foreach ($v as $key => $val) {
            if (!is_array($val)) {
                $in[$k][$key] = stripslashes($val);
                continue;
            }
            $in[] =& $in[$k][$key];
        }
    }
    unset($in);
}

https://www.php.net/manual/ru/function.get-magic-quotes-gpc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM