Jump to content
Nathan

How To Setup An .Htaccess File For Redirecting To Laravel’s Public Folder

Recommended Posts

htaccess.jpg

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×