1

Remove public from url laravel 5

remove public from url laravel 5

Remove public from url laravel 5.

Laravel is the one of the most popular framework now in these day. After installing the laravel you see it add public by default in url like http://example.com/public/. it’s not look good to use the public in the url it make url longer and ugly.

So, you need to remove the public from url to make the preety and seo frindly url. Let’s talk about the solution of /publlic/ from url.

There are 2 solution which i have found to remove public from url laravel 5

Using Htaccess

Create a .htaccess file in the root folder(if not exist). Now simply add the following code in your .htaccess file.

Using Moving Files

Moving Files is the best and simple method to remove public url. Just follow the follwing steps to do this.

1.Create a Folder in the laravel root directory named sp-laravel(you can give any name).
2.Move all files except public folder in the sp-laravel folder.
3.Move all the files of public to root directory and remove blank public folder.
so directory structure will be :-
remove public from url laravel 5

Now we need to change some paths in index.php file root folder
4.Find these files in index.php

change with below code

Now clear your browser cache and access url without /public/.

Sandeep Kumar

Sandeep kumar is a web developer and a professinal blogger. He works for latest technologies and write articles what he learn. In ICodeHub he share web languages tutorials and other programming tips and tricks. if you need some help or have some suggestion then mail him at sandeep92pal@gmail.com without any hesitation. He believes in learning and sharing.

  • Pingback: Laravel: Get base url - ExceptionsHub()