Question

I am trying to basic route to controller but this is not working and it says"

Not Found

The requested URL /member/john was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache Server at www.something.com Port 80

here is the code in routes.php:

<?php

Route::get('/', function()
{
    //This should return main index page of site
    return 'Hello Khalid';
});


Route::get('member/{name}', 'MemberController@printName');

and this is the controller:

<?php

class MemberController extends BaseController {

    public function index()
    {
        return 'Welcome Mr. John';
    }

    public function printName($name)
    {
        return "Welcome, " . $name;
    }
}

?>

Finally this is the URL am visiting:

http://www.domainName.com/member/john

Was it helpful?

Solution

mod_rewrite has to be activated to make routing work under apache.

OTHER TIPS

Add / to your route.

Route::get('/member/{name}', 'MemberController@printName');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top