laravel5.2 blog页面跳转404错误
Jun 06, 2016 pm 08:06 PM
项目为laravel网站上的项目:http://laravelacademy.org/post/2265.html
当部署完成后,用浏览器打开首页出现 /blog not found 的404错误。
routes.php代码如下:
<code><?php Route::get('/', function () { return redirect('/blog'); }); Route::get('blog', 'BlogController@index'); Route::get('blog/{slug}', 'BlogController@showPost'); ?></code>
尝试操作:
直接取消redirect重定向,修改成:
<code><?php Route::get('/', 'BlogController@index'); Route::get('/{slug}', 'BlogController@showPost'); ?></code>
并修改视图中的跳转链接,将 /blog/{slug}
修改成 /{slug}
结果,主页是出来了,但是二级页面还是出不来。提示404 notfound!
源码链接:https://github.com/digjack/Blog
回复内容:
项目为laravel网站上的项目:http://laravelacademy.org/post/2265.html
当部署完成后,用浏览器打开首页出现 /blog not found 的404错误。
routes.php代码如下:
<code><?php Route::get('/', function () { return redirect('/blog'); }); Route::get('blog', 'BlogController@index'); Route::get('blog/{slug}', 'BlogController@showPost'); ?></code>
尝试操作:
直接取消redirect重定向,修改成:
<code><?php Route::get('/', 'BlogController@index'); Route::get('/{slug}', 'BlogController@showPost'); ?></code>
并修改视图中的跳转链接,将 /blog/{slug}
修改成 /{slug}
结果,主页是出来了,但是二级页面还是出不来。提示404 notfound!
源码链接:https://github.com/digjack/Blog
在 Nginx,在你的网站配置中增加下面的配置,可以使用「优雅链接」
location / { try_files $uri $uri/ /index.php?$query_string; }
或者/index.php/blog

热门文章

热门文章

热门文章标签

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南

如何设置 Visual Studio Code (VS Code) 进行 PHP 开发
