Press ESC to close

Manoj Bist

How to remove public from laravel 5.4 url ( Laravel 5.4 )

How To Remove Public From Url in Laravel 

Hello friends, today I’m going to describe How To Remove Public From Url in Laravel 5.4 Project. I have searched in google for methods but no luck finally i came to the point, and i sort out the problem. I’m sharing this article because I believe there are other people like me who are just joining the Laravel Community.

Laravel is a very famous PHP Framework, because of flexibility and dependencies. It has expressive elegant syntax, application development with laravel is much more enjoyable and i believe you will enjoy too. It has powerful tools for Databases like eloquent Scout for full-text search and many more.

I’m assuming you have already installed Laravel 5.4

So Let’s begin the task
You can also follow this video

1. Renaming the server.php to index.php (no modifications)
2. Copy the .htaccess from public folder to root folder
3. Changing .htaccess a bit as follows :

 
RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...

RewriteCond %{REQUEST_FILENAME} !-d
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]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

That's it How to remove public from laravel.
enjoy!

Manoj Bist

A Passionate Web Developer/Designer With over 6 years of experience in the industry, Manoj Bist is a seasoned professional who combines technical expertise with a down-to-earth demeanor. As a lover of both technology and design, he thrives on creating seamless digital experiences that captivate and inspire.

Leave a Reply

Your email address will not be published. Required fields are marked *