21

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";
});
5
  • 1
    have you got mod_rewrite enabled on the server? Commented Jul 21, 2013 at 14:23
  • 2
    No, I don't. Does Laravel expect that? Commented Jul 21, 2013 at 14:36
  • 7
    Why the hell does Laravel not say in its shitty tutorial that we need to activate mod_rewrite ???? Commented Nov 3, 2013 at 20:58
  • 2
    @Panique welcome to the world of open source documentation. Commented Dec 27, 2013 at 9:37
  • This answer from delmadord save my life! stackoverflow.com/a/24785009/1419350 Commented Aug 19, 2015 at 1:38

4 Answers 4

45

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I have all that enabled, and I still can't get the second route to work. "/" works, "index.php/articles" works, but not "articles".
Just to follow up. The only way it worked was to make a virtual host (instructions here: apple.stackexchange.com/questions/30053/…)
I tried so many different things before falling onto this post. Great answer here, solved all my issues. Thanks for the great answer. Solution still working as of 7/28/2014
1

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".

Comments

0

You need mod_rewrite on. Try: l4/public/index.php/articles

2 Comments

Yes, I tried l4/public/index.php/articles and it worked. Now I'm trying to understand why. I have Apache 2.4 with mod_rewrite commented out. phpinfo() does not show mod_rewrite loaded. Laravel does have it's default .htaccess file. Is URL rewriting happening anyway? Why can't I use the path l4/public/articles?
I've already said it, you need to activate mod_rewrite, make some research. Also make sure you have this htaccess github.com/laravel/laravel/blob/master/public/.htaccess in you public folder
0

in httpd.conf change

<Directory />
    AllowOverride none
    Require all granted
</Directory>

to

<Directory />
    AllowOverride all
    Require all granted
</Directory>

then uncomment

#LoadModule rewrite_module modules/mod_rewrite.so

to

LoadModule rewrite_module modules/mod_rewrite.so

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.