Jump to content

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


Nathan
 Share

Recommended Posts

  • Administrators

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...