7

My setup currently looks like this

application/controllers/register.php

class register_Controller extends Base_Controller
{
    public $restful = true;
    public function get_index()
    {
        return View::make('main.register');;
    }
}

routes.php

Route::controller(Controller::detect());
Route::any('/', function()
{
    return View::make('main.index');
});
Route::any('register',function()
{
    return View::make('register.index');
});

mydomain.com works.

mydomain.com/index gives a laravel 404

mydomain.com/register gives a standard 404

What's strange is that shouldn't mydomain.com/register give me a laravel 404 error? This page indicates that WAMP was the cause, but my setup is on a Ubuntu VM running PHP5, Apache2, and mySQL.

Community
  • 1
  • 1
wonton
  • 7,568
  • 9
  • 56
  • 93
  • 2
    The last route? What is it for other than to tread on the controllers toes... that coincidentally needs to be capitalised from my understanding of Laravel, `Register_Controller`. I can't see why it's not throwing a laravel 404 mind you. – David Barker Aug 20 '12 at 23:03
  • I've already tried capitalizing, tried it without that last Route. I added it because nothing else works, and since routes are evaluated in the order presented it can't possibly tread on the controllers, right? My feeling right now is that something's wrong with the PHP settings. – wonton Aug 20 '12 at 23:05
  • 1
    Capitalised is correct, at least in terms of all the Laravel docs I've read. I can tell you that the last route is totally unecessary. If the controller isn't being auto detected declare it: `Route::Controller(array('register'));` – David Barker Aug 20 '12 at 23:08
  • 1
    Also is `register.php` in the controllers directory and not in a sub directory of it? – David Barker Aug 20 '12 at 23:09
  • register.php is not in a subdirectory. I've tried both the array and the single routing method, both to no avail. – wonton Aug 20 '12 at 23:16
  • Laravel is supposed to catch all 404s right? /index gets caught but anything else does not. I still feel like there's some PHP/Apache configuration issues. – wonton Aug 20 '12 at 23:19
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15590/discussion-between-david-barker-and-wonton) – David Barker Aug 20 '12 at 23:19

4 Answers4

10

With mod_rewrite on, try setting in apache configurations "AllowOverride All", it fixed it for me.

wonton
  • 7,568
  • 9
  • 56
  • 93
5

As Akash suggests, make sure your mod_rewrite is enabled. On Ubuntu use the following command to enable mod_rewrite on Apache:

sudo a2enmod rewrite

(You don't have to edit httpd.conf)
Do not forget to restart apache.

You can use the PHP command

phpinfo();

to check if mod_rewrite is working.

Hendrik Jan
  • 4,396
  • 8
  • 39
  • 75
3

make sure mod_rewrite is turned on in Apache (httpd.conf)

Un-comment the following line

LoadModule rewrite_module modules/mod_rewrite.so

and restart httpd

Akash
  • 4,956
  • 11
  • 42
  • 70
2

In addition, you should set your routes before you detect your controllers.

Route::any('/', function()
{
    return View::make('main.index');
});

Route::any('register',function()
{
    return View::make('register.index');
});

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