Mod rewrite does not work with laravel and bitNami

http.conf has mod rewrite uncommented

therefore, no custom routes work, someone from #laravel mentioned that this will be because mod rewrite does not work here, this 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 be displayed on

 http://localhost/ 

but not

 http://localhost/laravel 

which is preferred but secondary to the main problem

.htaccess inside the public folder has the following:

 <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 be resolved with

 http://localhost/laravel/test 

but instead i get 404 error

+4
source share
2 answers

RewriteBase and RewriteEngine are defined twice. Create the .htaccess file as follows:

 <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 better to use Apache virtual hosts.

0
source

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> 
0
source

All Articles