Learn how to remove “public” from the URL in Laravel 11 with this easy-to-follow example. Improve your Laravel app’s URL structure by configuring your project to remove the /public
directory from URLs. This guide provides step-by-step instructions and best practices for a cleaner, more professional URL in Laravel 11. Perfect for developers looking to optimize their web applications! You Can Learn How to Add Text to Image in Laravel 11 – Step-by-Step Guide
How to Remove Public from URL – Complete Guide with Example
This should help with visibility in searches related to Laravel URL configuration and optimization.
Solution 1: Laravel 11: How to Remove Public from URL – Complete Guide with Example
In Laravel, the .htaccess file can be generated and edited to incorporate new changes. The .htaccess file is located in the root directory, and its modification requires mod_rewrite to be enabled on your Apache server. It is mandatory to enable the rewrite module to implement these changes. Moreover, you need to activate .htaccess in Apache virtual host to use it in Laravel.
Finally, Just go to root folder and create .htaccess file and upload with following code
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
To remove “public” from your Laravel URL, you need to complete the following two steps:
1. Rename the server.php file in your Laravel root folder to index.php.
2. Copy the .htaccess file located in the /public directory to your Laravel root folder.
3. All public folder css and js file move to root folder.
I hope it can help you…