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

BrownieCoffee's avatar

Is it possible to have www.example.com url with app in subfolder (shared hosting).

Hi,

I have question. Actually my website url is www.example.com/folder.

Is it possible to have only www.example.com without move my app on root folder in shared hosting ?

Thank you by advance.

Bye .

0 likes
6 replies
MarianoMoreyra's avatar

Hi again @browniecoffee

Sure it's possible, you just have to point your Document Root to the corresponding folder. You should be able to that easily if your hosting has cPanel.

MarianoMoreyra's avatar

@browniecoffee if you have cPanel indeed, you just need to go to Domains option under the Domains section, and there you'll have all your domains with the Document Root configured for each.

There you can click on the manage button for the corresponding domain, which will allow you to change its Document Root.

rodrigo.pedra's avatar

Serving a Laravel app from a subfolder is not officially supported:

Docs: https://laravel.com/docs/8.x#directory-configuration

As @marianomoreyra said, sure It is possible with some configuration on your webservers.

But, as it is not officially supported, some features might not work as expected. For example: some users are reporting that route caching is broken in Laravel 8 if you serve your app from a subfolder.

Below are links to some GitHub issues, with core team members responses, for reference:

https://github.com/laravel/framework/issues/32236#issuecomment-609098208

https://github.com/laravel/framework/issues/32082#issuecomment-604986571

https://github.com/laravel/framework/issues/34362#issuecomment-693220173

https://github.com/laravel/framework/issues/32832#issuecomment-629628020

MarianoMoreyra's avatar
Level 25

Exactly @rodrigo.pedra !

Although actually my suggestion is to move the site from the subfolder to the root of the domain, without actually moving the code at file system level.

So, if he changes the webserver Document Root (be it Apache or NGINX) from the cPanel, he shouldn't need to move the code, but now be able to access the site at domain root on the browser.

So I guess we are basically saying the same (although my english can be confusing sometimes hehe).

1 like
laracoft's avatar

@browniecoffee

If you are trying to overcome the addon domain limitations of your hosting, it might be a better idea to use subdomains such as http://www.project.example.com instead of forcing with Laravel into a subfolder which has security implications and involves a lot of hackery.

Please or to participate in this conversation.