Skip to content

All topics  /  Laravel

How to Remove Public From URL in Laravel 9?

Laravel ·

Teams applying “How to Remove Public From URL in Laravel 9?” in a production project can use the corresponding workflow to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.

Before copying the example into a live application, confirm version-specific behaviour with the official Laravel website and test it against the project’s actual database and runtime.

This article will provide some of the most important example laravel 9 remove public from URL. This post will give you a simple example of laravel 9.htaccess to remove the public from URL. This tutorial will give you a simple example of remove the public from the URL in laravel 9. I’m going to show you how to remove public from URL in laravel 9 using htaccess. Alright, let’s dive into the steps.

Actually i had also problem in my laravel 9 application and i need to upload it in godaddy shared hosting. I remove public from url path using .htaccess and server.php file. You have to just two step and you can also done with your laravel 9 application. So let's do it.

Step 1: Rename File


In first step it is very easy and you need to just rename file name. you have to rename server.php to index.php at your laravel root directory.

server.php
INTO
index.php

Step 2: Update .htaccess first of all you have to copy .htaccess file and put it laravel root folder. You just copy .htaccess file from public folder and then update bellow code:

.htaccess

Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

Ok, now you can run and check it.

It will help you...