0

I have two routes, one works, the other does not and I cannot figure out why.

The first one works, when I visit the home page the view is displayed as intended.

Route::get('/', array('as' => 'homepage', function()
{
    return View::make('home');

}));

This second one comes up with a NotFoundHttpException error

Route::get('about', array('as' => 'aboutpage', function()
{
    return View::make('about');

}));

My other Laravel project works fine with this formatting and the home page works fine. If I visit localhost/laravel/public/index.php/about it works but `localhost/laravel/public/about does not.

I'm using WAMP and Apache module rewrite_module is on. I have restarted it multiple times.

3 Answers3

0

Try this code in .htaccess file of your project:-

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

RewriteEngine On

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

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Bit_hunter
  • 789
  • 2
  • 8
  • 25
  • That was already in there when Laravel created all the files. –  Jan 20 '15 at 03:34
  • 1
    This code is working fine in my Project. There is one more question on stack overflow http://stackoverflow.com/questions/15498513/apache-rewrite-for-laravel-public Try it. – Bit_hunter Jan 20 '15 at 03:40
0

I suggest you to do this:

1-try return 'hello' instead of the page:

Route::get('about', array('as' => 'aboutpage', function()
{
    return 'hello';
}));

2-try to do this stackoverflow

Community
  • 1
  • 1
  • Gave that a shot too but same issue kept occurring. What I ended up doing was just creating a new project and then copy and pasting the exact same code into it and it worked. It's really bizarre because the first project was a brand new one too. –  Jan 20 '15 at 22:07
  • No, the same thing happens. I just restarted the project and copied my code into it and it works. I have no idea what the reason was. –  Jan 21 '15 at 05:58
  • @MichaelN, OK I will remove this Answer –  Jan 21 '15 at 06:00
0

1) go to the httpd.conf file of the server and remove hash from line showing below

LoadModule rewrite_module modules/mod_rewrite.so

2)and replace AllowOverride none to AllowOverride All in same httpd.conf file

sunilwananje
  • 714
  • 5
  • 17