DEV Community

Kevin Farrugia
Kevin Farrugia

Posted on

Should I host two websites on a single domain?

I have two websites, one for mobile and one for desktop (i.e. this is not a responsive website). Both websites show similar (not identical) content for the same routes, so going to /about-us for each site would show the same content (80-90% similar, main content identical but peripheral content might change) within a different HTML structure.

Ordinarily, I would setup one website on m.mydomain.com and the other on mydomain.com. However we have been looking into using the same domain (no subdomains) for both websites.

A load-balancer would send the traffic to the respective server based on the user-agent (to recognise mobile/desktop traffic). This might seem similar to what Amazon.com does (not aware of the internal workings)

Is this setup a good idea or is it going to lead to problems?

Pros:

  • An improved user experience (debatable)
  • Possibly improved SEO as only a single website is indexed

Questions:

  • Will there be caching issues since assets are different? What about service-workers?
  • What about redirects? If one of the websites has a 301/302 redirect that is cached.

Top comments (4)

Collapse
 
crimsonmed profile image
Médéric Burlet

sub domain

You can use a sub domain to redirect mobile users to m.domain.com and keep the domain.com for web users.

This is something that is done on facebook for instance as the mobile app is much lighter than the browser.

middleware

Depending what you are using you can have a middleware that will point oto the proper place.

for instance this can be done easily on express where you would get the files from different folders but they would be served on domain.com

codeforgeek.com/how-to-detect-devi...

Collapse
 
imkevdev profile image
Kevin Farrugia

Thank you Mederic.

The implementation itself is not an issue as we have separate servers and a load balancer will handle the redirection (whether to a separate subdomain or same).

My question is more, which would you choose and why? Why subdomain? Why same domain? Does it make a difference?

Collapse
 
roka profile image
Robert Katzki

I would use the same domain. Something like m.mydomain.com feels old and is annoying when switching devices (I frequently send tabs to pocket or directly to another device via Firefox sync).

That said, as a user I would be irritated if the content changes when switching devices. I sure hope you have good reasons for this. Having two different layouts from the same HTML structure should be no problem using CSS Grid.

Collapse
 
imkevdev profile image
Kevin Farrugia

Thank you Robert.

Yes, I agree and usually a responsive website is my preferred option. In this case, the two applications are using slightly different implementations and the changes aren't only cosmetic/CSS. For example, on mobile we would request for less data and the user journeys would be different. Ultimately, it would be better suited for slower devices on flaky connection.