我正在对一个查询进行简单的分页。
页面底部的分页链接指向
http://localhost/reddit/public/subreddit/?page=1
http://localhost/subreddit?page=1
和错误
对象未找到!
在此服务器上找不到请求的URL。参考页面上的链接似乎是错误的或过时的。请通知该页的作者有关错误:
如果您认为这是服务器错误,请联系网站管理员。
错误404localhost
Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.11
但是如果我手动转到http://localhost/reddit/public/subreddit?page=2
页面加载良好。
这是config/app.php
中的url
'url' => 'http://localhost/reddit/public',
由于url设置为http://localhost/reddit/public
, Laravel将根据url配置生成相对链接。换句话说,它从所有链接中去掉http://localhost/reddit/public,只添加subreddit?page=1
将config/app.php
中的url
字段设置回'url' => 'http://localhost/',
应该可以解决这个问题