Get a free website with any plan

See how
APPLICATIONS

Laravel routes not working on shared hosting

Last updated

IN SHORT

When Laravel routes return 404 errors on Flashcloud shared hosting, the domain document root is usually pointing to the project root instead of its public folder. Point the document root directly at the public directory so requests funnel into index.php. This lets Laravel front controller and URL rewriting resolve routes properly.

If every Laravel route except the homepage returns a 404, the cause is almost always that your domain's document root points at the project folder instead of its public directory. Laravel's front controller and routing live in public/index.php, and everything outside that folder should never be reached directly by the web server. Point the domain at public, confirm mod_rewrite is active, and the routes that were 404ing will resolve.

Fix the document root

Laravel ships with a single entry point: public/index.php. Every request, whether it's / or /api/users/42, is supposed to funnel through that file, which boots the framework and hands off to the router. If you upload the whole Laravel project to a domain's root folder and it happens to work for / but breaks on any other path, the server is serving public/index.html or similar by accident, or Apache is trying to resolve routes as literal folders and failing.

On shared hosting, set the domain's document root to the project's public folder rather than the project root. If you're not sure how to change it on your account, open a support ticket and ask. If you're on a subdomain or addon domain, the same rule applies: it points at public, not at the folder containing artisan.

A common workaround when you can't change the document root (shared IP setups, addon domain restrictions) is to move the contents of public up to the domain root and edit the two paths in index.php that reference ../vendor/autoload.php and ../bootstrap/app.php to point one directory further up. It works, but it's fragile across deployments, so prefer setting the real document root whenever you have the option.

Check that .htaccess is doing its job

Laravel's public/.htaccess rewrites clean URLs to index.php so /about actually reaches the router instead of Apache looking for a literal file named about. If that file got stripped during upload, or a deploy tool skipped dotfiles, every route but the homepage will 404 even with the document root set correctly. Confirm it exists in public/ and contains the standard rewrite block:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

If that's present and routes still fail, the next suspect is whether mod_rewrite is enabled and AllowOverride permits .htaccess to apply. On our stack this is handled by LiteSpeed rather than stock Apache; LiteSpeed reads standard .htaccess rewrite rules natively, so a correctly formed file works without extra configuration. See How we make your site fast for more on how the LiteSpeed layer handles requests.

Match the PHP version Laravel expects

A mismatched PHP version produces a different symptom: a 500 error or blank page rather than a 404, but it's worth ruling out while you're in here since it stops routes from resolving too. Newer Laravel releases require modern PHP versions, so check your app's composer.json for the minimum it expects. Set the version for the domain from the PHP Version tile on your service page in the portal, choosing anywhere from PHP 7.4 through 8.3 (see Accessing cPanel if you need to get there through cPanel instead). That tile only switches the version; if you also need to raise upload_max_filesize, memory_limit, or similar values for a large Laravel app, do that separately in cPanel under Software → MultiPHP INI Editor.

After changing the version, clear any cached config with php artisan config:clear over SSH, since a stale cached config file can reference settings tied to the old PHP environment.

Rule out route caching

If routes worked in development but not after deploying, check whether a stale route cache shipped with the deploy. Laravel caches compiled routes into bootstrap/cache/routes-v7.php when you run php artisan route:cache, and if that cache is out of date or was generated against a different environment, new or changed routes silently won't match. Clear it over SSH:

php artisan route:clear
php artisan config:clear
php artisan cache:clear

Re-run route:cache only once you've confirmed routes work uncached, so you're not caching the same broken state.

When to open a ticket

If you've confirmed the document root points at public, the .htaccess rewrite block is intact, the PHP version matches your app's requirements, and routes still don't resolve, open a ticket from Support in the portal. Include the exact route that's failing, the response code you're seeing, and whether it happens on every route or specific ones.

Common questions

Why does only my homepage load while other pages show a 404 error?

Your web server cannot route requests to Laravel because the domain document root points to the wrong folder. Set the document root to the project public directory instead of the project root. This allows public/index.php to handle incoming route requests.

Can I run Laravel if I cannot change my document root?

Yes, but it requires a manual workaround. Move the contents of your public folder into your domain root, then update the paths in index.php pointing to autoload.php and app.php. Changing the actual document root is safer and less fragile across deployments.

Why did my new routes stop working after a deployment?

A stale route cache file is likely blocking them. Clear the compiled routes by running php artisan route:clear over SSH. You should also run php artisan config:clear to remove old configuration files.

What PHP versions are supported for Laravel on Flashcloud?

You can select any version from PHP 7.4 through PHP 8.3. Switch it from the PHP Version tile on your service page or through cPanel. Make sure the version matches the requirements in your composer.json file.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.