2

I'm writing my steps and findings here so you can see what I've tried and what results I got. Any advice would be welcomed. I followed the comments in this answer.

I'm running Laravel 4, using XAMMP version 1.8.2 with PHP 5.4.19 and Apache 2.4.4 on a Windows 7 machine and I'm simply still trying to get a local instance up and running.

In my case: http://localhost/sos/sos_public/ is my main screen and that works, but when I try to get to http://localhost/sos/sos_public/signup I get this error: Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException which has been talked about a lot on the net, and then I found GaryJ stating that it might be an .htaccess issue, so I did what he suggested.

My /app/routes.php file looks like this (I've tried this with a / in front of signup too):

Route::get('signup', function()
{
    return 'hello!';
});     

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

First:

Just for a laugh, see if /index.php/hello works. If so, then it's a .htaccess problem.

http://localhost/sos/sos_public/index.php/signup worked perfectly fine. So it's an .htaccess problem.

My .htaccess file looked like this:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

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

And:

if you're running Apache 2.4, note the changes since previous versions, regarding Require all granted and AllowOverride all within a <Directory />...</Directory> block on your virtual host.

I added this in my httpd.conf file as suggested by Dalton Gore - got the Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException error (changed this directory path to /SOS/sos_public and C:/xammp/htdocs/SOS/sos_public/ and C:/xammp/htdocs/SOS/sos_public - same results):

<Directory />
    AllowOverride none
    Require all denied
</Directory>
<Directory /SOS/sos_public>
    AllowOverride all
    Require all granted
</Directory>

Next:

Check if anything in .htaccess is working

I added dsjkdsfghk to my .htaccess file and immediately got an error, so I know my .htaccess file is being used.

Then:

Try removing the IfModule conditional. As you've got access to the host / vhost, you can soon enable that module if it's not - so it doesn't need be checked on every request. Equally, try moving it out of .htaccess, and into a <Directory />...</Directory> block in your vhost - if you've got nothing else in your .htaccess it can then be deleted as well.

  • Having an empty .htaccess file caused a 404 error in my browser for http://localhost/sos/sos_public/signup (http://localhost/sos/sos_public/ still worked).
  • Removing the .htaccess file from C:\xampp\htdocs\SOS\sos_public\ had the same results.

Then:

Try: <VirtualHost *:80> DocumentRoot "/Users/amiterandole/Sites/laravelbackbone/public" ServerName laravelbackbone.dev <Directory /> AllowOverride all Require all granted </Directory> <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </VirtualHost>

I did that and just like Amit,

I emptied out my htaccess file and tried the above and now nothing seems to work.

Except where his laravelbackbone.dev pointed to his Sites folder root, I just got an Error 400 - Bad request on both http://localhost/sos/sos_public/ and http://localhost/sos/sos_public/signup when I ran them in my browser.

My httpd-vhosts.conf file looked like this:

<VirtualHost *:80> 
    DocumentRoot "C:/xammp/htdocs/SOS/sos_public" 
    ServerName sos.dev
    <Directory /> 
        AllowOverride all 
        Require all granted 
    </Directory> 
    <IfModule mod_rewrite.c> 
        Options -MultiViews 
        RewriteEngine On 
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteRule ^ index.php [L] 
    </IfModule> 
</VirtualHost>

and in my .hosts file I obviously had:

127.0.0.1       sos.dev

Lastly:

You've definitely got the conf/extra/httpd-vhosts.conf file be included (uncommented) within the main httpd.conf?

I have this uncommented - yes.

Another link I tried but to no avail: https://stackoverflow.com/a/17778222/956975 and http://www.epigroove.com/blog/laravel-routes-not-working-make-sure-htaccess-is-working

What should I change where? What am I missing?

Community
  • 1
  • 1
marienke
  • 2,465
  • 4
  • 34
  • 66
  • what does your routes.php file look like? do you have a `get route` to `signup`? something like `Route::get('signup', function() { return 'Hello World'; });` – reikyoushin Sep 17 '13 at 20:36
  • Yes, please look at my question and you'll see that I've got Route::get('signup', function() { return 'hello!'; }); – marienke Sep 17 '13 at 20:40
  • that's weird.. hmm. do you have an updated version of l4 perhaps? – reikyoushin Sep 17 '13 at 20:47

2 Answers2

1

Your ServerName is

sos.dev

And apache take this in consideration, you you must access your routes using:

http://sos.dev/

And NOT

http://localhost/
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
  • I have the same issue: Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException error wether I use http://sos.dev/ or http://localhost/ or a Error 400 Bad request when adding the VirtualHost as suggested. – marienke Sep 17 '13 at 21:35
  • Could you show us your REDIRECT_QUERY_STRING and REDIRECT_URL from the error page (Server/Request Data)? – Antonio Carlos Ribeiro Sep 17 '13 at 21:39
0

It might be the error of not enabling rewrite Engine in apache2

In linux,

sudo a2enmod rewrite

sudo systemctl restart apache2

In windows,

You should find httpd.conf file if it's not available in your apache look for apache2.conf file is another name for httpd.conf and enable the rewrite module for more info or here see how to do above-said procedure in this link Lost httpd.conf file located apache

che
  • 61
  • 1
  • 11