Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel routes not working except for root

I have been spending hours on this issue and hope to find my way out. I have set up laravel correctly, created a project myapp

My route.php file just contains

Route::get('/', function()
{
return View::make('hello');
});

Route::get('/users', function()
{
    return 'Users!';
});

When I run

http://localhost/myapp/public/

I get the laravel start page correctly

When I run

http://localhost/myapp/public/users

I get

The requested URL /myapp/index.php was not found on this server.

I don't know why its looking for index.php.

When I run

http://localhost/myapp/public/index.php/users

I get a page with text "Users". I should obtain this page when running

http://localhost/myapp/public/users

instead.

Below is my .htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    Rewritebase /myapp/
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Any ideas? Am running a Apache on Linux.

like image 494
Kevin Joymungol Avatar asked Feb 24 '14 09:02

Kevin Joymungol


1 Answers

Your RewriteBase is set to /myapp/ but your index.php file is in /mayapp/public/ is it not?

As such, I think you'll find the RewriteBase needs to be /myapp/public/.

like image 164
alexrussell Avatar answered Nov 14 '22 23:11

alexrussell