我刚刚设置了我的作曲家并安装了一个新的laravel 5.4项目,我为apache服务器设置了一个虚拟主机。
虚拟主机配置
新申请的主页laravel.app
正常工作
但是当我添加一个新视图并为其设置路径时,例如:
//This is The default Home page route
Route::get('/', function () {
return view('welcome');
});
// This is the new Route
Route::get('/hello',function(){
return view('hello'); // I created another view with the name hello.blade.php
});
当我尝试使用链接laravel.app/hello
访问它时,我收到此错误:
未找到
在此服务器上找不到请求的URL / hello。阿帕奇/ 2.4.18 (Ubuntu)服务器在laravel.app端口80
我想提一下我的操作系统是Ubuntu 16.04
答案 0 :(得分:0)
首先检查是否启用mod_rewrite
。使用this question's answer。
第二次将.htaccess
文件放在.../public
中,其中包含以下内容:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]