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

aurelianspodarec's avatar

How to deploy two sites with one domain name, serving different content?

Hi there!

So I've deployed a Laravel webapp, lets say its dog.com.

The webapp works, database connected, the domain is live and all good dog.com works.

I'm using Digital Ocean, Apps features and Name Cheap for domains.

My question is, how can I server a new website under dog.com/docs? What DNS settings should I look at, what is this even called?

dog.com website is a Laravel webapp, but dog.com/docs should be a static HTML/CSS, some JS file with no database or anything.

How would you go about doing that?

0 likes
10 replies
undeportedmexican's avatar

I'm not an expert myself, but I think I can give you some pointers.

Since you have your laravel app in dog.com, basically all your requests will get redirected to dog.com/public/index.php. (This means, dog.com/docs will try to go to a route /docs in your laravel app).

I think you need to setup something in apache/nginix (whichever you're using) so that you inform the server that any request to dog.com/docs should go somewhere different.

1 like
aurelianspodarec's avatar

@undeportedmexican

So from what I understood, I need two separate servers.

The main server to host the back-end, with the domain name The second server where just the DNS id is used, but has the static files

Then proxy the dog.com/docs into that DNS while keeping the same name right.

Nginx reverse proxy or setting up symlinks on the server - something somehow. Got no idea about this stuff.

But that's the idea right. I deffo need two servers. So I could even host the docs from gh-pages I guess or netifly

undeportedmexican's avatar

@aurelianspodarec Not sure what you mean with servers.

Since it's the same domain, and you're not involving subdomains (eg. docs.dogs.com), dogs.com will ALWAYS be routed to the same IP.

You can have virtual hosts in your server, and that would do the trick. My question is, why don't you just put the static page inside the laravel app? Make the dog.com/docs route, and in the view just build the site you want to show. Would that not work?

2 likes
aurelianspodarec's avatar

@undeportedmexican

I'm essentially trying to replicate supabase https://github.com/supabase/supabase/tree/master/www - except the fact I want it to be in two separate repositories, not one.

The static page would be generated from https://docusaurus.io/ and I want to keep documentation code public, while server code private, so that wouldn't work in keeping it all public, id rather have that separate.

Although doesn't hurt to do it if this takes too much time, but learning new thing every hour so maybe will be able to achieve this xd

sr57's avatar

@aurelianspodarec agree with @undeportedmexican

DNS settings is only for domain or subdomains settings and dogs.com/doc is not a subdomain.

public/docs/index.html (or other pages) like every thing in public can be access (without route update)

1 like
aurelianspodarec's avatar

@sr57 Ah, I see.

What about proxy/nginix things like that?

So bit confused.

dog-backend, build in laravel will contain the dog-backend code, but dog-docs would have react app that would also compile

Does that mean I need to push both of the repositories into under one web server, build them on master push so when I push to dog-docs it doesn't build the main back-end but can also redirect the routing or whatever so it points elsewhere like undeportedmexican

Something like that?

aurelianspodarec's avatar

@sr57 Want to keep the site url clean and do it like others do it, such as supabase, tailwindcss etc...

So if I understood correctly, I need two servers. ( well I suppose one would be enough but easier to manage it in two servers with staging and stuff as far as I'm aware )

Then use nginix from dog.com to get files from a different server and configure the dog.com/docs right?

sr57's avatar

@aurelianspodarec

seems you have not understood what @undeportedmexican and I wrote before. A web server serves domains (or sub domains)

public can handle "static" web site(s)

how you update your (prod) server(s), with git, ... is another thing ... up to you to manage from different sources.

1 like
aurelianspodarec's avatar

@sr57 Thanks all.

I've managed to do that with Digital Ocean App features by setting a new static server, as a container(I believe that's what its called) inside the same app, and then change the routing HTTP routing to /docs from / on that server.

Now each time I go from my laravel app to /docs it automatically redirects me to the new host while keeping the same domain name, just adding /docs at the end.

Please or to participate in this conversation.