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

BuenosAires's avatar

Shared Hosting Deployment Symlink and 404 errors

I followed the guide provided in this forum for deploying a Laravel Project in shared hosting:

-/public content in /public_html

-other laravel content outside of /public_html in folder /ProjectName

-changed index.php routing to be now /../ProjectName/storage/framework/maintenance.php /../ProjectName/vendor/autoload.php and /../ProjectName/bootstrap/app.php

Then i tried to call php artisan storage:link and get symlink(): No such file or directory because the folder structure of the project has been modified from the default. How can i solve this issue?

Also whenever i tried to enter the website i always get redirected to WebsiteName.com/public even though that folder doesnt exist, and get an 404 error. Index.php(which is in /public_html) is being read fine because if i didnt make the pathing changes to it i would get the proper error of autoload.php not being found. So whats the deal? Im extremely lost on this as this is my first time deploying on shared hosting.

The Welcome page does require symlink to work because it shows images.

I also want to add: i can not create subdomains

0 likes
3 replies
LaryAI's avatar
Level 58

The issue with the symlink can be solved by specifying the full path to the storage folder in the command. For example, if the storage folder is located at /home/username/ProjectName/storage, the command would be php artisan storage:link /home/username/ProjectName/storage/public.

As for the 404 error, it could be caused by a misconfiguration in the .htaccess file. Try adding the following code to the top of the file:

RewriteEngine On
RewriteRule ^$ public/ [L]

This should redirect all requests to the public folder. If the issue persists, check the Apache error logs for more information.

It's also worth noting that some shared hosting providers have specific requirements for Laravel deployments, so it's a good idea to check with the provider's documentation or support team for any additional steps that may be necessary.

BuenosAires's avatar
BuenosAires
OP
Best Answer
Level 1

For anyone having the same issue in cPanel with no way to use SSH for symlink, just put the whole public(ONLY THE PUBLIC FOLDER THAT GETS SYMLINKED) storage folder in public_html, to fix the /public thing, wait one day so the server resets and stops trying to redirect there, it tried the first time because you probably had public_html/public/index.php so it just defaulted to where it found it the first time for the whole day.

Jsanwo64's avatar

It seems like you've encountered a couple of issues while deploying your Laravel project on shared hosting. Let's address each one separately:

Symlink Error: When you modified the folder structure of your Laravel project, the default symlink created by the php artisan storage:link command won't work because the storage folder is now located outside the public_html directory. To solve this issue, you can manually create the symbolic link to the storage folder. Here are the steps to follow:

Connect to your shared hosting account using SSH or the hosting provider's file manager. Navigate to the public_html folder. Delete the existing storage folder if it exists. Create a symlink from the public_html folder to the storage folder using the following command:

ln -s /full/path/to/ProjectName/storage/app/public storage

Replace "/full/path/to/ProjectName" with the actual path to your Laravel project's storage folder. By creating this symlink, the Laravel application will be able to access the storage files from the public folder.

Redirection to /public and 404 Error: The issue you're facing with the redirection to /public and the resulting 404 error could be due to incorrect routing configuration. To fix this, make sure you have made the necessary changes to the index.php file located in the public_html folder. Open the index.php file and modify the following lines:

Change:

require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

To:

require __DIR__.'/../ProjectName/vendor/autoload.php';
$app = require_once __DIR__.'/../ProjectName/bootstrap/app.php';

Make sure to replace ProjectName with the actual folder name where your Laravel project resides outside the public_html directory.

After making these changes, save the index.php file and try accessing your website again. It should now correctly route to your Laravel application.

Remember to ensure the necessary permissions are set on the folders and files, as required by Laravel, to avoid any further issues.

If you continue to encounter any problems, please provide more specific details about the error messages or any other relevant information.

Please or to participate in this conversation.