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

Sajjad Ali's avatar

Hosted site accessible with /public

Everything works fine on my local environment, but on hosting, all routes are accessible with /public except for homepage.

So when i go to example.com/public it doesn't work and give 404 error, but if go to example.com/public/someroute that is accessible. Similarly all other routes like /public/categories, /public/categories/posts etc.

Google Search Console is excluding all URL's with /public because of canonical settings.

Any help please. How to fix this.

0 likes
6 replies
Sajjad Ali's avatar

Not on shared hosting. It's VPS setup on runcloud.io. /public is default folder with runcloud.io setup. .env and all other files lives outside as they should be.

/.env is not accessible.

Sinnbeck's avatar

Then I wouldnt expect your site to be called at /public. It should be run at the root domain, not a subfolder

Sajjad Ali's avatar

It's working with root domain. Google is indexing all URL's with root domain and excluding same URL's with /public. I just noticed excluded URL's and found this strange issue. When i checked homepage with /public it was showing 404 error page but as mentioned, all other routes are working including all posts, categories with /public. Which is strange. I checked site on my localhost (setup with laragon) and i can't access same routes with /public.

Could it be .htaccess issue on hosted site?

Please note that .htaccess file inside /public folder is unmodified. And all local and hosted files are in sync via github repository.

Sajjad Ali's avatar
Sajjad Ali
OP
Best Answer
Level 7

I found the issue. Runcloud.io have setting for public path in app > settings, where i needed to add /public directory. Which fixed the issue.

I checked /.env file and multiple other files which are outside public directory and none of them were accessible. Site was working fine with root domain as well.

Hopefully this will help some other users on runcloud.io if they miss that public path setting for laravel app.

Thanks @sinnbeck

1 like
Sinnbeck's avatar

Good to hear. And thanks for updating your post with the answer. I am sure others will run into the same issue. Mark you own answer as best to set the thread as solved.

1 like

Please or to participate in this conversation.