Subdomain on a different root

Hello,

I just created a subdomain and the system automatically set up a directory for it. I am using a laravel project and set up routes for the subdomain within the project. I would like my subdomain’s root to be the same as my main domain’s. Is it possible?

Thanks

No, it’s not possible for a base domain and a subdomain to share a document root

Is there any workarounds to this then?

Yes, you can work around this with .htaccess rules:

Thank you for your response.

I have checked that one already and set up my .htaccess accordingly but it works only for the main domain itself where if you have the both the projects files and .htaccess at the same location.

Here in my case though, the subdomain root folder is in a different location and I am pretty sure I can’t go into the previous locations with .htaccess. Or can I?

If the main htdocs changed places then yes, you cannot modify that with .htaccess.

So I currently have these directories:

I need to somehow change play around with the .htaccess under the subdomain folder to point it out to my main Laravel installation. Is this possible? I can very well just copy the project files also under the subdomain, but that would not be sustainable, would it.

No, it’s not possible to point a subdomain to another domain. To do this you need to modify the server configurations, which is not possible in any way by just playing around with .htaccess.

Having subdomains point to the same website location is not possible, and neither is joining them together under the hood.

The options I can give you are:

  • Upgrade to premium hosting, where you can fully configure which directory of your account your domains are linked to.
  • Consider moving the content on the subdomain to a sub-path of your website (so instead of having blog.example.com, host it on example.com/blog/ instead).