Remove public from url in laravel project

Created at 19-Jul-2021 , By samar

Remove public from url in laravel project

Through the use of the programming language, we will work together to solve the "Remove public from url in laravel project" puzzle in this lesson.

You can easily remove the public from URL in laravel. There are lots of ways to remove the public from the URL. The most convenient way is to use the htaccess file.
  • Remove public from url in laravel using htaccess file in root directory of project

    --PATH .htaccess
    <ifmodule mod_rewrite.c>
     
        <ifmodule mod_negotiation.c>
            Options -MultiViews
        </ifmodule>
         
        RewriteEngine On
         
        RewriteCond %{REQUEST_FILENAME} -d [OR]
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteRule ^ ^$1 [N]
     
        RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
        RewriteRule ^(.*)$ public/$1 
     
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ server.php
     
    </ifmodule>
    

    You have to copy-paste code snippets to your .htaccess file which you have to create in the root directory of your project. To access your images, scripts, and style files you have to move the CSS, JS, and images folder from the public directory to your root directory.

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.