Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel htaccess in root directory

I want to host my Laravel 4 project on free webhosting. To work, the hosting root dir must point to the "public" folder of my project where is taking place the .htaccess file. I did not succeed with finding free hosting which allows changing the root dir so I tried to place another .htaccess file in the main project dir which redirects to the public folder. Then the landing page opens but non of the routes in routes.php works. So my question is:

Is it possible to put the .htaccess file from "public" to the main dir and the application to work properly ?

Hope my question was clear.

like image 618
Alexander Nikolov Avatar asked Oct 24 '25 11:10

Alexander Nikolov


1 Answers

Yes, you can do that from create a .htaccess file in your laravel root directory.and put below code in that file.

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>

It should be redirected easily.

  • Another way to remove public folder

    for more reference click here....

like image 137
Jigs Virani Avatar answered Oct 26 '25 23:10

Jigs Virani