S
S
Sergey Melodin2018-02-26 14:49:34
PHP
Sergey Melodin, 2018-02-26 14:49:34

How to configure Vagrant to work with routing?

If I understand correctly, in general, Homestead solves my issue in the case of full-fledged frameworks. However, now I'm analyzing the simplest "course" example:

function router($uri)
{
    switch ($uri) {
        case '/about':
            return '<h1>This about</h1>';
            break;
        default:
            return '<h1>This not about</h1>';
            break;
    }
}

$uri = $_SERVER['REQUEST_URI'];
echo router($uri);

If you run a server in linux and access localhost/about, then the answer is returned, however, in the browser on the local machine (windows), the main page is loaded, but the routing magic does not happen.
Tell me the solution or links for the correct Google :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksim Fedorov, 2018-02-26
@melodyn

There are purely problems with the web server, you need to look at the nginx settings
. By default, Homestead includes all requests for index.php except for folders and files.
Here is the default nginx setting in Homestead:
https://github.com/laravel/homestead/blob/master /s...

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question