我的源代码在 https://github.com/xsmyqf/startlaravel.git 在分支userauth。
我有一个问题,当我访问localhost / startlaravel / public / cats / create时,打印页面未找到! 但是最令人困惑的是页面完全存在于文件夹中,并且路径文件中有一个cat / create路径!
可以在分支主机中访问相同的路由!除了添加身份验证之外,我什么都不做。
感谢您的任何想法!
我搜索了谷歌,但我真的不知道为什么我不能访问现有的路线!
答案 0 :(得分:2)
<trq> The reason is routes are processed in order. The cats/{cat} route matched but was unable to find anything by that id.
<xxs> cats/create can match /cats/{cat}
<xxs> cats/{cat} have )->where('id', '[0-9]+');
<trq> /cats/{cat} matches any string that looks like /cats/whateverthehellisthis
<xxs> cats/{cat} have )->where('id', '[0-9]+');
<xxs> only allow number
<trq> your not using id anywhere
<trq> that should likey be ->with('cat', '[0-9]+');
<xxs> oh!smart eyes
<xxs> I got it
<xxs> thanks very much
答案 1 :(得分:1)
你的路径将是startlaravel / cats / create
如果您的安装目录是startlaravel,如果您在/ var / www /中有laravel,那么您应该访问
http://127.0.0.1/cats/create
或
http://127.0.0.1/cats
答案 2 :(得分:1)
假设你试图通过转到
来查看它http://localhost/startlaravel/public/cats/create
在您的浏览器中(或类似的东西)。
您不想访问startlaravel/public/cats/create
,而是cats/create
。所以,
http://localhost/cats/create
原因是,public是根目录,而不是startlaravel。