Deployment in a subfolder with Laravel and Filament PHP on shared hosting

I have build a simple property management application using Laravel 11 and Filament v3. I deployed the application in two places. Both on shared hosting. The only difference is one is deployed under a subdomain under public_html. So both applications are working one on is accessible on for example https://exampledomain.com and the other on https://testdomain.com/subfolder I can load the login page on both but the second on https://testdomain.com/subfolder only works if I delete the routes cache. If the route is cached and I load https://testdomain.com/subfolder, I get an error stating Method Not Allowed Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The GET method is not supported for route /. Supported methods: HEAD. When I delete the route cache the login page loads. The main issue is when I put in my login details on the second domain with the route cached deleted I get an error saying Method Not Allowed Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The POST method is not supported for route user/login. Supported methods: GET, HEAD. I have edit the .htaccess file RewriteEngine On RewriteBase /subfolder/ I have the below routes in my web.php file <?php use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Route; Route::get('/', function () { return redirect('/user/login'); })->name('home'); Route::get('/clear-cache', function() { Artisan::call('config:clear'); Artisan::call('route:clear'); Artisan::call('cache:clear'); Artisan::call('view:clear'); return 'Done'; })->name('clear-cache'); Route::get('/cache', function() { Artisan::call('filament:optimize'); Artisan::call('optimize'); return 'Done cache'; })->name('cache'); I have cleared routes, cache and views with no luck. Exact same project works perfectly on https://exampledomain.com without the subfolder Any suggestions?
3 Replies
WernerACT
WernerACTOP5mo ago
I have also set the APP_URL in the .env to match the https://testdomain.com/subfolder and ran php artisan config clear.
Andi
Andi5mo ago
This is more likely due to wrong webserver setup. How does your nginx conf or whatever webserver you use look like? Better use a subdomain so, subfolder.testdomain.con
Dennis Koch
Dennis Koch5mo ago
Shared Hosting is always a struggle with Laravel. Can you set the DocumentRoot with the shared hosting? Otherwise it's not secure.
Want results from more Discord servers?
Add your server