Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Roy Penrod
Roy Penrod
19,810 Points

Laravel 4 Basics -- Having Trouble Getting Additional Routes to Work

I'm just getting started with Laravel 4 and trying to learn how it works. I added the following code to the routes.php file.

Route::get('/', function()
{
    return View::make('hello')->withName('friend');    
});


Route::get('/test', function()
{
    return View::make('hello')->withName('test');    
});

I'm running this on a WAMP server on Windows 7.

The path to my app is: localhost/laravelbasics/public

When I visit the first url it works fine:

But it gives me a 404 "file not found" error when I visit the test route: 
```localhost/laravelbasics/public/test```

Any clue what I'm doing wrong?

4 Answers

Roy Penrod
Roy Penrod
19,810 Points

Alright, I found out what was going wrong.

To get it to recognize the new route, I had to use this as the URL:

http://localhost/laravelbasics/public/index.php/test

Kind of a weird way to do it, but hey it works now. That was painful. lol

jason chan
jason chan
31,009 Points

localhost/laravelbasics/public/test

you made the route /test

Roy Penrod
Roy Penrod
19,810 Points

It gives me a 404 when I visit localhost/laravelbasics/public/test, Jason. It's not hitting the route "/test" that I created.

All of the routes should be relevant to the /public directory, right?

So if I created a route "/duh", you should reach it at localhost/laravelbasics/public/duh, right?

Or am I missing something about Laravel routing?

Hello roy..im sorry but this is not a answer for ur question. I am looking for project team members to work on my projects. Right now my team consists of only 3 people including me and i would really like you to join me :) .

My team is now working on an existing project of mine and trying to improve it to the maximum we can but after 18th of this month we are planning to build a social networking website. If u are interested....email me at lakindu1.jayathilaka@gmail.com or https://www.facebook.com/lakistealthhacker

thanks have a good day

Roy Penrod
Roy Penrod
19,810 Points

Appreciate the offer, but I'm really busy right now, Lakindu. Trying to pad out my portfolio to go after a specific job. Good luck with your project.

Roy Penrod
Roy Penrod
19,810 Points

Yes. The view is working for the root route, but the same view will not work for the test route. If you look at my code above, the only difference is the route and the value of the same variable.