O
O
Oleg Gamega2016-04-25 23:05:51
PHP
Oleg Gamega, 2016-04-25 23:05:51

How to properly set up rewrite in nginx?

How to properly set up rewrite in nginx for slim to work?
url parameters do not work,
for example, it works without parameters

$app->get('/', function ($request, $response, $args) {
    $response->write("Welcome to Slim!");
    return $response;
});

but no parameters
$app->get('/hello[/{name}]', function ($request, $response, $args) {
    $response->write("Hello, " . $args['name']);
    return $response;
})->setArgument('name', 'World!');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Kainazarov, 2016-04-26
@gadfi

I use laravel and lumen for them something like this is suitable

server {
    listen 80;
    server_name some.site.my;

    root /var/www/some.site/web/public;

    index index.html index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location / { 
        try_files $uri $uri/ /index.php?$query_string;
    } 

   error_log /var/www/some.site/web/logs/error.log;

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question