1. Home
  2. GetFund – A Professional Laravel Crowdfunding Platform
  3. Installation
  4. Remove public from URL -Laravel 5+

Remove public from URL -Laravel 5+

For the security reasons, Laravel keeps public accessible files and index.php in the public directory in root. So the public can not access your core directory structure. You can point your domain to the public directory for accessing directly domain.

But if you want to remove public from URL badly. you can follow the below steps to get it without making any modification in your domain root path. You can get it by the sevaral way.

Method 1

  • Rename server.php in your Laravel root folder to index.php
  • Copy the .htaccess file from the directory /public to your Laravel root folder.

Done, try browsing without public in URL, you should go homepage

Another Method 2 (Risky)

This is too much risky for your application or website, because of it makes your composer.json, .env and others sensitive files or information publicly accessible via the browser. Good practice is to set your virtual host to /public or point domain to the public directory. So if you want to go ahead with this instruction, please continue.

Copy .htaccess, index.php and others directory from the public folder to root directory. Then change root index.php code as below

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

Now all set, and try to browse your website without public

Don’t forget to prevent .env file accessing by url

Hide .env from your .htaccess located in the root directory, open it by a text editor and add below code snippet at the end of the page, so your all of credential will be store securely.

<files .env>
order allow,deny
deny from all
Was this article helpful to you? Yes No

How can we help?