I am trying to use Laravel 5.1 for the first time. I was able to install it, and https://sub.example.com/laravel/public/ shows what should. However, the views I create give me a 404 error page that was not found.
Here is what I have done so far:
I created a controller in laravel\app\Http\controllers\Authors.php
Here is the code for the Authors.php file
<?php class Authors_Controller extends Base_Controller { public $restful = true; public function get_index() { return View::make('authors.index') ->with('title', 'Authors and Books') ->with('authors', Author::order_by('name')->get()); } }
Then I created the view in laravel\resources\views\Authors\index.blade.php
Here is the code for index.blade.php
@layout('layouts.default') @section('content') Hello, this is a test @endsection
Then I created the layout in laravel\resources\views\layouts\default.blade.php
Here is the default.blade.php file code
<!DOCTYPE html> <html> <head> <title>{{ $title }}</title> </head> <body> @if(Session::has('message')) <p style="color: green;">{{ Session::get('message') }}</p> @endif @yield('content') Hello - My first test </body> </html>
Finally I created a route in laravel\app\Http\routes.php
<?php Route::get('/', function () { return view('welcome'); }); Route::get('authors', array('as'=>'authors', 'uses'=>' authors@index '));
But for some reason I get an error 404 Page not found.
I enabled mod_rewrite on my Apache 2.4.9, uncommenting the line
LoadModule rewrite_module modules/mod_rewrite.so
Then restarted Apache.
From what I can say in the output of php_info() , mod_rewrite is enabled
Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_php5 mod_access_compat mod_actions mod_alias mod_allowmethods mod_asis mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_socache_shmcb mod_ssl
My current .htaccess file looks like this: "This is the factory default setting"
Options -MultiViews
RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
I also tried changing it to the code below as per the documentation :
Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
However, I still get page 404 when I go to
https://sub.example.com/laravel/public/authors
What am I doing wrong? How can I solve this problem?