php - laravel controller doesn't work -
1. i'm following codehappy: using controllers learn use laravel controllers, in pc "myproject/" points "wamp/www/laravel/public" folder, when try "myproject/account/login" browser shows:
not found
the requested url /account/login not found on server.
2. obviously, browser tries find "account" folder instead of using controller, created "account" folder under "public" , tried again, guess proved right. should config anywhere before using controllers?
my code:
application/controllers/account.php
<?php class account_controller extends base_controller { public function action_index(){ echo "this profile page."; } public function action_login(){ echo "this login form."; } public function action_logout(){ echo "this logout action."; } }
/application/routes.php
route::get('/', function() { return view::make('home.index'); }); route::controller('account');
@phill sparks has right (rightfully so! he's been using laravel ages). if browser reporting 404 server, unless removed 404 event, request did not go through laravel.
try /index.php/account/login
. if works, know rewrite rules botched. if doesn't work either, have more serious issue @ hand.
if using apache, should find in htaccess
file rewrite rules laravel. if cannot load mod_rewrite through htaccess, you'll need migrate them server config.
if using nginx, need similar in server
block:
location / { try_files $uri $uri/ @laravel; } location @laraveldesktop { rewrite ^/(.*)$ /index.php?/$1 last; }
or if in subdirectory
location /my/subdir/ { try_files $uri $uri/ @laravel; } location @laravel { rewrite ^/my/subdir/(.*)$ /index.php?/$1 last; }
Comments
Post a Comment