Posts Learn Components Snippets Categories Tags Tools About
/

How to Remove Public from URL in Laravel 8 Application

Learn how to silently rewrite the public URL from being accessible in Laravel 8 application the easy way

Created on Oct 08, 2021

382 views

In this short snippet, you will learn how to silently rewrite all of your base URIs to the "public" folder located at the base of the Laravel project. This will work even for all Headers, for example, the HTTP Authorization Header, and all optional URI parameters will silently be passed on to the /public folder as well.

Create htaccess File


Firstly do create a new htaccess file in the root project like below. 
.htaccess
Then the content of the htaccess will be as follows.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)