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

wanderlusted's avatar

How to deploy laravel 7 app with subdomain to a subfolder on shared hosting?

I'm trying to deploy a laravel 7 app from my local machine to my shared hosting provider. The app has a public part and an administration part. The routes of the administration part are under a subdomain. Users can go to the public pages and then login to the admin part. On the local machine everything works fine: the user goes to localhost/login and after login gets redirected to admin.localhost/home.

I deployed the app to a subfolder under public_html at my shared hosting space as it is described here: https://dev.to/fractalbit/deploy-a-laravel-7-app-to-shared-hosting-4eac

When I enter mydomain.com/mysubfolder the app is properly loaded. However when I'm trying to log in to the admin area, after the login the redirection wants to go to admin.mydomain.com/home but I get a "404 We're sorry, the page you requested cannot be found." message. I created an admin.mydomain subdomain under cpanel and pointed it to the subfolder where my app is located, but it did not help.

So to summarize my question: what steps do I need to take to deploy an app to subfolder on a shared hosting space, if my app also has a subdomain part, so that everything works correctly?

Thanks! W.

0 likes
2 replies
Punksolid's avatar

Hi @wanderlusted how are your routes for admin?

If its not important I think its easier and more safe to change the subdomain to an specific path like mydomain.com/admin

Because in shared hosting maybe you need to add a wildcard for subdomains or register the specific subdomain to point to the same directory you have.

However shared hosting can have specific configurations for your webserver.

Regards

wanderlusted's avatar

@punksolid Thanks, I will consider replacing the subdomain with a path, if there is really no solution to this. I already created an admin.mydomain subdomain that points to the folder that contains my app, but as I wrote above, for some reason the page is not found. Let me know, if you have any thoughts on how to debug and fix this. Thanks!

Please or to participate in this conversation.