php - laravel5.2 blog页面跳转404错误
本文介绍了php - laravel5.2 blog页面跳转404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
项目为laravel网站上的项目:http://laravelacademy.org/post/2265.html
当部署完成后,用浏览器打开首页出现 /blog not found 的404错误。
routes.php代码如下:
<?php
Route::get('/', function () {
return redirect('/blog');
});
Route::get('blog', 'BlogController@index');
Route::get('blog/{slug}', 'BlogController@showPost');
?>
尝试操作:
直接取消redirect重定向,修改成:
<?php
Route::get('/', 'BlogController@index');
Route::get('/{slug}', 'BlogController@showPost');
?>
并修改视图中的跳转链接,将 /blog/{slug}
修改成 /{slug}
结果,主页是出来了,但是二级页面还是出不来。提示404 notfound!
源码链接:https://github.com/digjack/Blog
解决方案
在 Nginx,在你的网站配置中增加下面的配置,可以使用「优雅链接」
location / {
try_files $uri $uri/ /index.php?$query_string;
}
或者/index.php/blog
这篇关于php - laravel5.2 blog页面跳转404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文