Use 2 URL for different parts of the same app


#1

Hi,
I need advice on how to setup my app.

Basic idea : I want my app accessible by 2 different URL :

  • domainA .com, my main url which point to my root page
  • domainB .com, which points to another page of my app : domainA.com/pageB

I don’t have any database issue, since my database can be shared between the two apps.

My setup now is
domainA -> AWS ELB -> 1 Instance AWS
and I use MUP to deploy, so no NGINX special configuration for now.

Ideally the user browsing with domainB .com won’t see the redirection to domainA .com

Is there any solution which can allow me to keep a single instance (and ideally still use MUP), and not having to use 2 instance and duplicate my app ?

Thanks !


#2

What about other URLs?
Will domainB.com/this/url will be the same as domainA.com/pageB/this/url?
Will all URLs in domainB be the same as domainA.com with a prefix (pageB)?
Or only the first page is different and than other URLs are the same?


#3

I am open to all suggestion in oder to keep it simple

I don’t mind re-defining all my pages in the rooter, and I don’t mind have all my domainB.com/this/url to be the same as domainA.com/pageB/this/url


#4

For the simplest answer (just change the home of domainb.com, other urls are the same) I manage to do it like this with iron-router (add domainb.com to your /etc/hosts for testing):

Router.route('/', function () {
    let hostname = window.location.hostname;
    if (hostname === 'domainb.com') {
      this.render('pageb');
    } else {
      this.render('home');
    }
  },
  {
    name: 'home',
    waitOn: function () {
      if (window.location.hostname === 'domainb.com') {
        return [
          Meteor.subscribe('pageb_publish_1'),
          Meteor.subscribe('pageb_publish_2')
        ];
      }
      return [
        Meteor.subscribe('home_publish_1'),
        Meteor.subscribe('home_publish_2')
      ];
    }
  }
);

#5

Hi,
Thanks for your reply

I can understand your comment about the router part.

But I still can’t figure what happens when the user connect with the domain name.
For now, my domainA DNS points to my loadbalancer, which points to the IP of my server.
In this process, the URL domainB.com get transformed into domainA.com

Which part of my setup does this transformation ? is it a configuration of MUP ?