Remove “public” from url in laravel project.

In laravel framework by default, all the route will get after the “public” in URL like http://localhost/my-project/public/myroute. There are some solution for avoiding the public from URL, Here I’ll show you a simple solution where you don’t have to setup extra configuration in live server. You don’t have to think about a virtual host or is the project in local or remote server. Let’s see the process.ess.

The steps are:

  1. First go to your public folder and cut the files (index.php,htaccess) then paste these files into your project root directory.


  2. . Now open the index.php file and find the two lines .
    require __DIR__.'/../bootstrap/autoload.php';
    $app = require_once __DIR__.'/../bootstrap/app.php';
  3. Now change the lines like as
    require __DIR__.'/locale/bootstrap/autoload.php';
    $app = require_once __DIR__.'/locale/bootstrap/app.php';

Finished! Now you can browse your project without entering the public word in the URL. You need not configure extra things in your live server. Just upload the full project files into your share hosting public_html directory and enjoy!

Tags : , , , , , , ,

Share on :

One Response to “Remove “public” from url in laravel project.”

  1. jaman says:

    Thanks, for these But you should mention. Two thing.
    that is locale directory where use. If it will work on xampp or local environment then it will have to remove cookie and cache from browser. Thanks.

Leave a Reply

− three = 3