0

I am very new to laravel and I simply don't get how to route properly, am completely lost. The problem is I can only route a view to localhost/public. For example I can't route a view to "localhost/public/something". Am not even sure my urls are correct. If i leave "something.php" empty nothing will show, but if i add some html it shows only the html no views. Am sure am doing it all wrong. So how does one route a view to a page other than "public/". The routing for index is

Route::get('/', function(){
    return View::make('welcome');
});

works okay.

Now how can I achieve the same if do

Route::get('something', function(){
    return View::make('welcome');
});

or

Route::get('/something', function(){
    return View::make('welcome');
});

So i finally got it to work after so many hours. I deleted my laravel installation and did a new one and the problem is gone. Thanks.

ifeoluwa king
  • 531
  • 1
  • 8
  • 19
  • Have you tried running your laravel project as a Virtual Host? eg. when working with XAMPP accessable via "myproject.dev:8080" – Krenor Oct 26 '15 at 14:10
  • I am working with wamp. How do i go about it – ifeoluwa king Oct 26 '15 at 14:13
  • Try [this guide](https://john-dugan.com/wamp-vhost-setup/). I'm using XAMPP so I don't know if this is all correct. But your route is set up right, so it might be the URL that somehow messes that up. But I always set up a VH when starting a laravel project. – Krenor Oct 26 '15 at 14:15
  • hi. I am weary of tampering with localhost settings as i really don't understand it and don't want to mess it up. But thanks anyway, still no luck though. I would keep trying – ifeoluwa king Oct 26 '15 at 18:03

1 Answers1

2

There's nothing wrong with your code but might be for .htaccess

Please try accessing the route via following URL http://localhost/public/index.php?/something

if it's working, you need to use the alternative .htaccess file provided on Laravel website or see if mod_rewrite is loaded on your Apache.

Saman
  • 59
  • 1
  • 6
  • Thanks but still no luck although http://localhost/public/index.php?/something is giving me a more useful error message: NotFoundHttpException in RouteCollection.php line 161: – ifeoluwa king Oct 26 '15 at 18:04
  • Have you tried [this configuration](http://laravel.com/docs/5.0/configuration#pretty-urls)? – Krenor Oct 27 '15 at 08:16
  • @Yado htaccess doesn't matter when you access the route via index.php . the error (NotFoundHttpException) he faced is because the route has not been loaded or he might have used route cache. – Saman Oct 27 '15 at 09:20