Categories
Apache Laravel

Laravel remove public from url

When you setup a new laravel website you want to get rid of that “/public” in the url. Here is a direct code which you can paste into .htaccess file of root to remove that annoying “public”

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

Or if you have domain access then you can just point your domain to public folder directly.

Leave a Reply

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