4

http.conf has mod rewrite uncommented

so no custom routes are working someone in #laravel mentioned it would be because mod rewrite isn't working here is my setup:

laravel.conf has the following code:

Alias /laravel/ "C:\BitNami/frameworks/laravel/public/"
Alias /laravel "C:\BitNami/frameworks/laravel/public"

<Directory "C:\BitNami/frameworks/laravel/public">
Options +MultiViews
AllowOverride None
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
</Directory>

If I uncomment these lines:

#RewriteEngine On
#RewriteRule ^/$ /laravel/ [PT]

then the main route will map to

http://localhost/ 

rather than

http://localhost/laravel 

which is preferable but secondary to the main problem

.htaccess inside the public folder has this:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
RewriteEngine On
 RewriteBase /laravel
 </IfModule>

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

here is my test code inside routes.php:

Route::get('test',function(){
return 'test worked';
});

which should resolve with

http://localhost/laravel/test 

but instead I get a 404 error

arcanine
  • 1,933
  • 1
  • 15
  • 22

2 Answers2

0

RewriteBase and RewriteEngine are defined twice. Make your .htaccess file look like this:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /laravel
</IfModule>

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

If possible, it would be best to use Apache virtual hosts instead.

Codeplus
  • 131
  • 5
  • I had the same idea, and deleted those lines before this post but I had the same problem, I've copied and pasted your answer into .htaccess in the public folder of laravel but alas I still have the same problems as described in original post – arcanine Feb 10 '13 at 13:22
  • How would I go about adding a Apache virtual host? – arcanine Feb 10 '13 at 13:23
  • I never used BitNami, just noticed the duplication in the .htaccess file. When I was running Windows, I used [WampServer](http://www.wampserver.com/en/). You would have to edit the httpd-vhosts.conf file and add the new site information. There is usually an example. Then in your Windows hosts file (c:\Windows\System32\drivers\etc\hosts) add `127.0.0.1 example.com` – Codeplus Feb 10 '13 at 15:56
0

Your .htaccess file should look like this.

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

    RewriteEngine On

    # Redirect Trailing Slashes...    
    RewriteRule ^(.*)$ public/$1 [L]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Vivek Pandey
  • 396
  • 5
  • 10