peaks
peaks

Reputation: 167

Laravel routing (?) problems

So I just uploaded my site from my local dev environment to my server. But there's a problem. Only the index page loads. I've mapped some controllers to different routes like this:

//controller detection
Route::controller(Controller::detect());

//site routes
Route::get('/','site@index');
Route::get('about','site@about');
Route::get('blog','site@blog');
Route::get('downloads','site@downloads');
Route::get('products','site@products');
Route::get('shop','site@shop');

//admin routes
Route::get('login','admin@login');

//ajax functions
Route::get('loadnews/(:num)','ajax@loadnews');
Route::post('sendmessage','ajax@sendmessage');
Route::post('loadblog','ajax@loadblog');
Route::post('loadblogdetails','ajax@loadblogdetails');

Event::listen('404', function()
{
    return Response::error('404');
});

Event::listen('500', function()
{
    return Response::error('500');
});

Route::filter('before', function()
{
    // Do stuff before every request to your application...
});

Route::filter('after', function($response)
{
    // Do stuff after every request to your application...
});

Route::filter('csrf', function()
{
    if (Request::forged()) return Response::error('500');
});

Route::filter('auth', function()
{
    if (Auth::guest()) return Redirect::to('login');
});

And when I click on the links pointing to these routes, I've get a simple Error: 324 (net::ERR_EMPTY_RESPONSE): from chrome.

How can I fix this?

The site currently located at: site

Upvotes: 1

Views: 2894

Answers (5)

enga
enga

Reputation: 315

It appears you are using Linux, but in case this is applicable for future readers with the same issue:

For me, the issue was that I am running my app on Windows Server 2008 R2 and I hadn't set up the htaccess properly through my IIS Manager. I hadn't realized I needed to do this because for other sites, my htaccess files were working fine, but none of them were using mod_rewrite.

The solution was to install "IIS URL Rewrite Module 2", which I then could use from the IIS Manager, where I would choose to "Import" everything from the default htaccess file included with Laravel.

After that, all pages loaded, not just the index.

Upvotes: 0

dataphile
dataphile

Reputation: 352

I had to put the root route, in your case :

Route::get('/','site@index'); 

at the bottom of the routes.php file

Upvotes: 0

Cheluis
Cheluis

Reputation: 1412

I was having a similar problem, and I resolved it deleting the line:

Route::controller(Controller::detect());

I'm using named Url's. Give it a try.

Upvotes: 3

Sean
Sean

Reputation: 1888

At least on my end I was able to fix this problem by adding. RewriteBase / to the .htaccess file. Now everything seems to be working properly.

Upvotes: 1

David Barker
David Barker

Reputation: 14620

Make sure you register the controller if you haven't.

Route::controller(array('site'));

If you're using Apache on your server, make sure mod_rewrite is on and configured as well as a decent .htaccess rule set, laravel comes with a pretty decent .htaccess for Apache servers.

Also make sure you have removed the 'index.php' base url from Application config.

These are probably the most common reasons why Routes don't work. You can also test your routes from the command line that makes this process a little simpler:

php artisan route:call get about

Upvotes: 0

Related Questions