Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel (and generic) framework setting for "Public" folder

I tried to make Laravel works on my environment (MAMP) but i'm stuck in this situation.

The index.php file of Laravel is into a subfolder called "public", so if I want to test my application I need to access it with this url http://localhost/laravel/public/ but I want access with http://localhost/laravel

I tried to set an htaccess with this rows but it doesn't work:

<IfModule mod_rewrite.c>  
    RewriteEngine on
    RewriteRule ^(.*)$ public/$1
</IfModule>  

I'm not sure that this htaccess can resolves this situation, I get a 404 generated by Lavarel.

like image 585
MatterGoal Avatar asked Dec 26 '22 23:12

MatterGoal


2 Answers

You need to create a virtualhost. Dayle Ress covers this in the first chapter in his Laravel book: https://web.archive.org/web/20121013083457/http://daylerees.com/2012/03/25/laravel-getting-started/

like image 184
Niall O'Brien Avatar answered Dec 29 '22 13:12

Niall O'Brien


Put .htacess file in root with code:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
like image 24
RDK Avatar answered Dec 29 '22 13:12

RDK