Blenderer
Blenderer

Reputation: 702

Apache redirect is failing for Laravel

I have mod_rewrite enabled on Apache2 and AllowOverride All in the default file. However Apache (After restarting) still can't seem to redirect when given a pretty url from Laravel.

WORKS (Returns: Users!): localhost/laratest/public/index.php/users

DOESN'T WORK (404): localhost/laratest/public/users

My .htaccess: (I've also tried the one suggested in the Documentation to no avail)

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

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

Laravel routes.php:

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

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

I am using the default LAMP stack and configuration in Ubuntu. Any ideas why this isn't working?

Upvotes: 0

Views: 1674

Answers (2)

Mike Rock&#233;tt
Mike Rock&#233;tt

Reputation: 9007

Have you set your RewriteBase to /laratest/public?

Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /laratest/public
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Upvotes: 1

ehp
ehp

Reputation: 1699

As suggested on the laravel website (http://laravel.com/docs/installation#pretty-urls) try this other one:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Upvotes: 0

Related Questions