简体   繁体   English

Laravel路由无法正常工作

[英]Laravel routing not working correctly

Quick question, 快速提问

EDIT: I do not know how to access other routes besides '/' Here are the routes I want to access 编辑:我不知道如何访问除“ /”以外的其他路由这是我要访问的路由

Route::get('/', 'HomeController@index');

Route::get('users', 'UserController@index');

Route::get('foo', function()
{
    return 'Hello World';
});

Here is my routes. 这是我的路线。 Via php artisan routes 通过php artisan路线 在此处输入图片说明

I can successfully access localhost/cartraderlaravel/public It takes me to HomeController@index 我可以成功访问localhost / cartraderlaravel / public将我带到HomeController @ index

when I try to access foo or users I get 当我尝试访问foo或用户时,我得到 在此处输入图片说明

I have tried 我努力了

localhost/cartraderlaravel/public/users localhost/cartraderlaravel/users localhost/cartraderlaravel/foo localhost/cartraderlaravel/public/foo 本地主机/ cartraderlaravel /公共/用户本地主机/ cartraderlaravel /用户本地主机/ cartraderlaravel / foo本地主机/ cartraderlaravel /公共/ foo

All of these return a "Not Found" error. 所有这些都返回“未找到”错误。 Help anyone? 帮助任何人?

You should point your root directory to cartraderlaravel/public in WAMP so that you need not to visit localhost/cartraderlaravel/public. 您应该将根目录指向WAMP中的cartraderlaravel / public,这样就不必访问localhost / cartraderlaravel / public。 To do that in WAMP follow : 要在WAMP中执行以下操作:

  1. Click on WampServer icon in taskbar 单击任务栏中的WampServer图标
  2. Select Apache > httpd.conf from the pullup 从下拉菜单中选择Apache> httpd.conf
  3. Search for the term “DocumentRoot” 搜索术语“ DocumentRoot”
  4. Change the DocumentRoot path to your custom directory 将DocumentRoot路径更改为您的自定义目录
  5. Search again for “DocumentRoot” again same procedure 再次按照相同的步骤再次搜索“ DocumentRoot”
  6. Save your changes and “Restart All Services” 保存更改并“重新启动所有服务”

Further research shows this is a common problem with WAMP. 进一步的研究表明,这是WAMP的常见问题。 Something to do with Apache settings. 与Apache设置有关。 I have moved to using a virtual network and everything works now 我已经开始使用虚拟网络,现在一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM