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

cisco's avatar

Deploying Laravel to subdirectoy [Digital Ocean VPS]

I keep getting a 404 Not Found whenenver I navigate away from the index page. After extensive googling and sleeping on it, I just can't wrap my head around on how to resolve this issue.

My directory structure is as follows, note I'm deploying to subdirectory on a subdomain:

/var/www/dev.site.io/
├── public_html/
│   ├── img/
│   ├── mobile/
│   ├── styles/
│   ├── se/
│   └── index.html
└── laravel/
    ├── app/
    ├── bootstrap/
    ├── ... 

The path I'm trying to deploy to is se/ (se short for software engineering for a project). Now rather then just copy the contents in Laravels public/ directory as other threads have mentioned, I softlinked the contents of the public/ folder to the se/ folder as other threads have mentioned as well.

Also ran in write permissions so set chmod 775 to Laravels storage/ folder and everything worked, but..navigate away from the index.php and I'm hit with 404 Not Found. I've included my routes below, any help is appreciated.

<?php

Route::get('/', function () {
    return view('pages.index');
});

// Authentication routes
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// Registration routes
Route::get('/register', 'Auth\AuthController@getRegister');
Route::post('/register', 'Auth\AuthController@postRegister');

// Protected routes
Route::get('/dashboard', ['middleware' => 'auth', function() {
    return view('auth.dashboard');
}]);

I'm aware I could just create another subdomain on my VPS and set the document root to point to the public/ folder, but I'm determined to get it to work in a subdirectory.

0 likes
3 replies
shez1983's avatar

have you set the base path? changed settings into config so laravel know where the actual index.php and other files are?

cisco's avatar

@shez1983 I'm not sure what you mean by this. Is that something set in the .env file or? I don't think that would be the issue since everything lives within the laravel folder. I think the issue is with the compiled blade templates maybe? Which would have to do with as you said the paths, but I'm not sure how to proceed from here.

shez1983's avatar

i think in the config/app file, you have base_url which you can change to use .env file..

also in the index.php file there is a REQUIRE statement or two.. make sure their path is proper..

Please or to participate in this conversation.