How to remove Public from URL in Laravel 5?

5+

Laravel framework is awesome to use. But for beginners, it might be irritating to fix the issue where user needs to goto /public file to access newly created project. If that is your case, well, you are at right place.

The process is very simple with only 2 steps. Here are the steps.

  1. Goto to your laravel root folder of your project and you will find server.php file.
  2. Rename server.php to index.php.
  3. Now goto /public folder and find .htaccess file. If you don’t find .htaccess file, it means you have turned off show hidden file setting in your computer. Here is steps on how to show hidden files.
    1. Mac users:
      1. Press Command+Shift+. and you will be able to see all hidden files.
      2. And if you want to hide again, Please the same keys and you are done. So easy.
    2. Windows users:
      1. Under View menu, check Hidden items And you are good to go.
  4. Copy the .htaccess file from /public folder to your Laravel root folder.
  5. Now open your website localhost:8888/your_project. Isn’t is working now? I hope so.

This way, you can enable accessing your website directly from your root folder instead of typing /public which doesn’t even look better for the website. I hope once day Laravel team will do the changes within its framework without need to do anything at first place. But till that time, well here is the solution for you guys.

I hope, this helped you. If so, don’t forget to share and it would be highly appreciated if you give a like for this post. Let me know if you have problem. I will be happy to help you.

Thanks

5+

Leave a Reply

santoshm