How to Setup an .htaccess file for redirecting to Laravel’s Public Folder

By March 22, 2018 No Comments

In Laravel the path for serving your web page is in the /public folder. By default after installing Laravel and navigating in a browser to the URL you will see a directory listing of all the Laravel files.  Here’s an easy way using an .htaccess file to redirect requests to the Laravel /public folder user mod_rewrite.

Create a .htaccess file in your root directory and add the following code.

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Save your file and refresh your browser, you should now see the default Laravel splash page.

Leave a Reply