Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 simple route not working using mod_rewrite, and .htaccess

Tags:

I'm not only new to Laravel 4, but new to using frameworks. I thought I'd start with Laravel since it's gotten such good reviews. I've got a good install of Laravel. I go to /l4/public and see the welcome page.

I'm trying to add a route to routes.php so that when I navigate to /l4/public/articles I get a response.
I get "The requested URL /l4/public/articles was not found on this server." Do I need to run an artisan command to compile the routes? It's probably something easy. Why this message?

routes.php

Route::get('/', function() {     return View::make('hello'); });  Route::get('articles', function () {     //return View::make('articles');     return "Articles hello there"; }); 
like image 662
Alex_B Avatar asked Jul 21 '13 13:07

Alex_B


2 Answers

Problem is solved by two editing changes in apache's httpd.conf file.

AllowOverride None is default. AllowOverride controls whether .htaccess files are processed.

mod_rewrite is commented out by default.

Changes to make:

Change 1: Activate mod_rewrite by uncommenting it.

Change 2:

Change

AllowOverride None 

to

AllowOverride All 

Now restart Apache...

The default .htaccess file that Laravel provides in the public folder specified some mod_rewrite rules. These rules were not getting applied because AllowOverride was set to none. Be sure and restart apache after changing these settings. My configuration: Apache 2.4.6 on Windows XP.

It appears that there may be some security implications to the AllowOverride change. If anyone has additional information on this, I would like to hear it.

like image 61
Alex_B Avatar answered Sep 21 '22 11:09

Alex_B


That Error basically say that the router cannot found your request. Make sure you already save your changes. if you using the artisan command to running the page,just re-run again command "artisan Serve".

like image 26
reptildarat Avatar answered Sep 19 '22 11:09

reptildarat