Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mdev11's avatar

Run the website from public folder without public in URL

Usually, I create a sub-domain and change the Document Root to the public folder like public_html/subdomain/public so when I visit https://subdomain.example.com it runs from the public folder without needing to add public in the URL.

Now I have a Laravel project on a sub-folder on a sub-domain public_html/subdomain/subfolder and I want to run the project from the public folder to avoid this https://subdomain.example.com/subfolder/public.

The website is hosted on a VPS server so I have access to everything.

How to make the project on the subfolder on the subdomain runs from the public folder without adding /public to the URL?

0 likes
1 reply
LaryAI's avatar
Level 58

To run a Laravel project from the public folder without adding /public to the URL, you can follow these steps:

  1. Move all the files and folders from the public folder to the subfolder on the subdomain (public_html/subdomain/subfolder).
  2. Edit the index.php file in the subfolder on the subdomain and change the following line:
require __DIR__.'/../bootstrap/autoload.php';

to:

require __DIR__.'/../../bootstrap/autoload.php';
  1. Also, change the following line:
$app = require_once __DIR__.'/../bootstrap/app.php';

to:

$app = require_once __DIR__.'/../../bootstrap/app.php';
  1. Save the changes and try accessing the website without adding /public to the URL.

Note: This solution assumes that the Laravel project is installed in the root directory of the subfolder on the subdomain. If it is installed in a subdirectory, you will need to adjust the paths accordingly.

Please or to participate in this conversation.