我是Lavarel框架的初学者.我知道MVC struct ,因为我以前在ASP中使用过它.net,但使用Laravel对我来说相当困惑.
我已经在photozoom
个目录中安装了Laravel,使用:
composer create-project laravel/laravel photozoom --prefer-dist
这是我的app/routes.php
:
<?php
Route::get('/', function()
{
return View::make('hello');
});
Route::get('users', function()
{
return 'users route is working!';
});
当我跑http://localhost/photozoom/public/users
,我得到404 Not Found
个错误.
但当我try http://localhost/photozoom/public/
时,会调用/
的路由,并调用相应的视图.
我甚至试图为users
号路由创建一个视图.使用Laravel文档.我创建了两个文件:
layout.blade.php
:
<html>
<head>
<title>Laravel Quickstart</title>
</head>
<body>
<h1>Laravel Quickstart</h1>
@yield('content')
</body>
</html>
users.blade.php
:
@extends('layout')
@section('content')
Users!!!
@stop
但是,当我打http://localhost/photozoom/public/users
时,我得到了404 Not Found error
.
这是我的public/.htaccess
份文件:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我使用的是PHP5.5和Apache2.4.6.
任何帮助都将不胜感激.
SOLVED