htaccess for clean urls not being read by apache?

I’m getting kinda crazy over here because I already wasted two hours getting my clean URLs enabled for the laravel framework.

I’m on a Mac and have a XAMPP setup. The Loadmodule mod_rewrite is commented out and php_info() says mod_rewrite module is loaded.

My .htaccess file in the public folder of the laravel framework contains the code for cleans URLs (as stated on their website) but still, when I surf domain.com/account it gives me a 404.

The laravel framework folder runs as a virtual host.

What could it be, that is going wrong?!

<IfModule mod_rewrite.c>
     RewriteEngine on

     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d

     RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Answer

Make sure Loadmodule mod_rewrite is uncommented.

Make sure you have AllowOverride set appropriately for the vhost to allow .htaccess to do its thing.

One example of a good directive is:

<Directory "/some/absolute/path/htdocs">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory> 

A good patter to follow for .htaccess for what you are trying to do is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Very close to what you are doing.

Restart your apache server.