Home / Snippets / How to Remove Public from URL in Laravel 8 Application
How to Remove Public from URL in Laravel 8 Application cover

How to Remove Public from URL in Laravel 8 Application

413

2 years ago

0 comments

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]
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this