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.
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!

Leave a Reply