Routes en laravel 5.5

2

Dear

I'm learning laravel 5.5 and I'm trying routes,

in routes / web

add the following route

Route::get('/usuarios',function (){
    return 'usuarios para agregar';
});

so that when the link put link I returned the string but instead it gives me an error that the page does not exist, I'm watching a tutorial and the teacher does it that way and does not have that inconvenience.

any help?

beforehand thank you very much

    
asked by Pablo Moraga 02.02.2018 в 20:12
source

3 answers

2

The problem seems more of a system than Laravel. Does the UR link work?

I see two options that the host is wrong C: \ Windows \ System32 \ drivers \ etc \ hosts In homestead

192.168.10.10  miproyecto.app

better .app pq .com can redirect to a web.

The .env on the route of the Laravel tb can give problem

APP_URL=http://miproyecto

I advise you if you are starting, use HOMESTEAD.

Homestead Documentation

    
answered by 03.02.2018 в 13:36
1

Apparently you work with an apache server (xampp or wamp), since that problem occurs in both sets confuse laravel routes. I recommend some things like:

1 .- Work with homestead

2 .- Create a virtual host

3.- It is not recommendable but it works correctly and it is a quick solution, what you would have to do is edit the index.php of xampp that should be in the following path: C : \ xampp \ htdocs \ index.php

index.php: You must have the following content

<?php
    if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
        $uri = 'https://';
    } else {
        $uri = 'http://';
    }
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri.'/dashboard/');
    exit;
?>
  

You change it by:

<?php
    if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
        $uri = 'https://';
    } else {
        $uri = 'http://';
    }
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri.'/miproyecto/public');
    //header('Location: '.$uri.'/dashboard/'); //solo lo comentas para que no se te olvide
    exit;
//?>

As you can see, only one line code was changed, and after that, you just rebooted Apache and your project would be in localhost and all the routes will work. Of course, what happens is that the xammp dashboard does not work but it is solved leaving the code as the original reason why you only comment that line.

    
answered by 04.02.2018 в 02:36
0

A little late, but I hope I can help someone. I had the same problem but in my case I used the address 'localhost' and simply the problem was that I did not respect the capitals that had the names of the folders at the time of writing the URL, but I could still access 'public' by showing me the screen main, but it does not work with the routes, write exactly URL respecting capital letters and maybe solve your problem.

    
answered by 17.11.2018 в 17:14