在Laravel中无法正确路由 [英] Can't route properly in Laravel
问题描述
我对laravel还是陌生的,我根本不知道如何正确地进行路线安排,完全迷路了.问题是我只能将视图路由到localhost/public.例如,我无法将视图路由到"localhost/public/something" .甚至不确定我的网址是否正确.如果我将"something.php"留空,则不会显示任何内容,但是如果我添加一些html,则只会显示html 没有视图.肯定做错了一切.因此,如何将视图路由到除"public/"之外的页面. 索引的路由为
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');
});
可以.
现在我该怎么做
Route::get('something', function(){
return View::make('welcome');
});
或
Route::get('/something', function(){
return View::make('welcome');
});
如此多小时后,我终于让它工作了.我删除了laravel安装并进行了新的安装,问题解决了.谢谢.
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.
推荐答案
您的代码没有错,但可能适用于.htaccess
There's nothing wrong with your code but might be for .htaccess
请尝试通过以下URL访问路线 http://localhost/public/index.php?/something
Please try accessing the route via following URL http://localhost/public/index.php?/something
如果运行正常,则需要使用Laravel网站上提供的备用.htaccess文件,或者查看是否在Apache上加载了mod_rewrite.
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.
这篇关于在Laravel中无法正确路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!