Can't route properly in Laravel

◇◆丶佛笑我妖孽 提交于 2019-12-19 11:45:16

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/33347704/cant-route-properly-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!