I
I
iddddy2019-08-26 19:01:22
Nginx
iddddy, 2019-08-26 19:01:22

Multiviews Apache in Nginx?

The script is written for Apache with Multiviews, if there is no Multiviews, a file with the following content is connected:

<?php
//die('Only enable this script if you dont have support for MultiViews');
$relative = '';
$loaders  = array(
    'ajax' => 1,
    'album' => 1,
    'albums' => 1,
    'blog' => 1,
    'blogs' => 1,
    'captcha' => 1,
    'categories' => 1,
    'community' => 1,
    'confirm' => 1,
    'notfound' => 1,
    'feedback' => 1,
    'feeds' => 1,
    'game' => 1,
    'games' => 1,
    'index' => 1,
    'invite' => 1,
    'loader' => 1,
    'login' => 1,
    'logout' => 1,
    'lost' => 1,
    'mail' => 1,
    'notice' => 1,
    'notices' => 1,
    'photo' => 1,
    'requests' => 1,
    'search' => 1,
    'signup' => 1,
    'static' => 1,
    'stream' => 1,
    'upload' => 1,
    'user' => 1,
    'users' => 1,
    'video' => 1,
    'videos' => 1,
  'edit' => 1,
    'embed' => 1,
    'view' => 1,	
  'ads' => 1
);

$query      = ( isset($_SERVER['QUERY_STRING']) ) ? $_SERVER['QUERY_STRING'] : NULL;
$request    = str_replace($relative, '', $_SERVER['REQUEST_URI']);
$request    = str_replace('?' .$query, '', $request);
$request    = explode('/', trim($request, '/'));
if (isset($request['0'])) {
    $page   = $request['0'];
    if (isset($loaders[$page])) {
        require $page. '.php';
    } else {
    header('HTTP/1.0 404 Not Found');
  		die();
  }
} else {
  header('HTTP/1.0 404 Not Found');
    die();
}
?>

connected it to Nginx:
location / {
   try_files $uri $uri/ /loader.php;
}

Normal requests like site.ru/videos work, and site.ru/videos?o=mv gives 404, tell me how to fix it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-08-26
@dodo512

try_files $uri $uri/ /loader.php;

try_files $uri $uri/ /loader.php?$args;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question