This guide will show you how to make your Laravel application's public folder open directly when you enter your domain in the browser.
Scenario
You've installed Laravel on your primary domain in your public_html
folder (root directory). However, you want your visitors to access your site without seeing the default domain.com/public
URL. Follow these steps to set up a seamless experience.
Steps
Locate or Create .htaccess
File
In your public_html
(root directory) or domain root folder, look for a file named .htaccess
. If you don't see it, dotfiles might be hidden in your File Manager. Adjust your settings to show hidden files, or create a new file named .htaccess
.
Add Rewrite Rule
Open the .htaccess
file and add the following code snippet:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
- Save Changes
Save your changes to the file.
Result
After completing these steps, both you and your visitors should be able to access your Laravel application's public folder directly via domain.com
.
Note
If you encounter issues accessing your site, you might need to clear your browser cache to ensure the changes take effect.