Home > Back-end >  How to hide public from url in laravel 9
How to hide public from url in laravel 9

Time:05-19

I used Laravel 9 and Inertia.js Vuejs and the project has been deployed to the cpanel. When I access to the site and it threw an error saying Not Found with code 404 so then I added a new file - .htaccess outside the public folder and the error existed. I tried to access to public folder like this https://imapp.asomaningministries.com/public and it worked but I don't want anyone to eventually access to this folder. So can I hide it?

CodePudding user response:

You can try to set the document root directory as 'public' directory on the domain settings page of cPanel.


or you can use .htaccess file like that;

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
  • Related