Laravel-How to remove the public folder from URL

Once you install laravel framework on your local machine or hosting server, by default it build all the url’s consisting public folder in them. For example in your local machine it would be like this ;

http://localhost/<virtaul folder>/public/ , In my case it was as follows

http://localhost/restaurants/public/

On your hosting server it would be like;

http://yourdomain.com/public/.

So this is not going to be a pretty good site when it comes to SEO. URL’s should be meaningful and SEO friendly.

Remove laravel pulblic folder

How do we avoid the public folder from the url and make it a clean URLs for laravel projects? It is pretty simple. You can do this by moving all the contents of the public folder in to root directory. Then by changing few settings in the paths.php file and index.php file you can get rid of public folder from laravel project urls.

You can locate your paths.php file inside the bootstrap folder (laravelfolder/bootstrap/paths.php). You can do the following changes to it;