How to deploy Laravel (with Filament) to a cPanel shared hosting in separate folders?
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
How to Deploy Laravel (with Filament) to cPanel Shared Hosting in Separate Folders: A Developer's Guide
Deploying a modern framework like Laravel, especially with complex admin panels like Filament, to shared hosting environments can introduce significant hurdles related to file permissions, routing, and server configuration. The scenario you described—attempting to deploy separate development and staging environments on cPanel—is common, but it requires precise knowledge of how the web server (Apache/LiteSpeed) interacts with your application structure.
As a senior developer, I can tell you that the issues you are facing (403 errors and broken authentication flow) are almost always related to misconfigured public directory access and improper handling of entry points, rather than an error in the Laravel code itself.
Here is a comprehensive guide on how to correctly structure your deployment to achieve a working setup.
Understanding Shared Hosting Constraints
Shared hosting environments impose strict limitations compared to a dedicated VPS. You are generally limited to what the hosting provider allows you to modify via cPanel. The key challenge is ensuring that the web server serves the correct index.php file as the entry point for your Laravel application, while maintaining security permissions.
When deploying separate instances (e.g., /public_html/develop and /public_html/staging), you must treat each directory as a completely independent, isolated application root.
Step 1: Correct File Structure and Placement
The standard Laravel deployment requires that the public-facing files are accessible via the web server root. Since you want separate folders, ensure your structure mirrors this separation perfectly.
For your develop environment, assume the following structure within your cPanel directory (e.g., public_html/develop):
/public_html/develop/
├── .htaccess <-- Crucial for routing
├── index.php <-- The Laravel entry point
├── composer.json
├── vendor/
└── public/ <-- This is often where the web server points, though we will adjust this.
└── index.php <-- If you place the entire framework inside a subdirectory.
Best Practice: For shared hosting, it is usually safest to have your core Laravel files reside in the main deployment folder, and the public assets (which point to the application) are served from there. Given your requirement for separate folders, ensure that each deployed folder contains its own complete set of framework files necessary for runtime.
Step 2: Mastering the .htaccess File for Routing
The 403 errors you encountered stem from the server not knowing how to handle the URL requests directed at /develop or /develop/public. The .htaccess file is your primary tool for telling Apache how to route requests internally within the Laravel structure.
For a standard Laravel deployment, the .htaccess file must be placed in the root directory of your application (e.g., /public_html/develop/.htaccess). It needs to correctly handle URL rewriting and direct traffic to index.php.
Here is a robust starting point for your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ index.php [L]
</IfModule>
This simple rule tells the server: "For any request, pass it through to index.php." This is essential for Laravel's internal routing mechanism (which relies on the public folder being the document root). If you are deploying a full application structure into a subdirectory, you may need additional rules to handle path stripping correctly, ensuring that /develop/public/admin is correctly interpreted by the framework.
Step 3: Resolving Filament Authentication Issues
The problem where the login form loads but fails authentication points toward an issue with session handling or middleware execution. With shared hosting, ensure that your .env file variables (especially APP_URL) are set correctly to reflect the subdirectory structure (http://yourdomain.com/develop).
Laravel relies heavily on the correct setup of its service providers and routing definitions. When deploying custom setups, always verify that you have followed Laravel’s documentation regarding environment configuration before pushing code to a live server. For advanced concepts like efficient API design or framework architecture, consulting resources from laravelcompany.com is highly recommended.
Conclusion
Deploying Laravel and Filament to cPanel shared hosting in separate folders is achievable, but it demands meticulous attention to file permissions and server configuration files. The key takeaways are: isolate your environments completely, use the .htaccess file correctly as the gateway for all traffic, and treat each deployed folder as a standalone application root. By mastering these concepts, you move from fighting server errors to confidently managing complex application deployments.