How to Remove Public From URL in Laravel
Laravel 27-Nov-2020

How to Remove Public From URL in Laravel

Remove the public from URL in laravel. In this tutorial, we will learn how to remove the public from URL in laravel.

Remove Public From URL Laravel

There is two way to remove public from URL in laravel

  • Create .htaccess file and update content
  • Raname server.php and move .htaccess file

Create .htaccess file and update content

Now Create and update the .htaccess file in the Laravel. You can find .htaccess file in root directory.

You must have mod_rewrite enable on your Apache server. The rewrite module is required to apply these settings. You also have enabled .htaccess in Apache virtual host for Laravel.

Update the code into your .htaccess file:

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

Rename server.php and move .htaccess file

Here, you can follow the below steps for remove public from url in laravel

  1. The first step is, Rename server.php in your Laravel root folder to index.php
  2. Copy the .htaccess file from /public directory to your Laravel root folder.

Conclusion

In this tutorial remove the public from URL in laravel. Here you have learned two ways to remove the public from URL in laravel.

If you want to learn more about laravel click here.