Share
How to remove public from url in laravel 9
Question
Is it possible to remove “public” from the URL for a Laravel application and just safely upload the entire app folder to my public_html folder on my server? Thanks
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Answers ( 1 )
You could just run
and you won’t have the “public” in the url. It’s not safe to mess around with htaccess.
In your root Laravel app, create a file called server.php with the following content:
Then create a .htaccess file in the same place with the following content
Now you should be able to access your site without the “public” in the url. But as Boon said, it’s not the intended way to use Laravel.
You should also check if you can access your .env file like so: yoursite.com/.env
You should get a 404 or access forbidden error.