We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27672
    • 168 Posts
    i am consolidating 6 sites that are all done in different languages/cms’s and by different people into one modx installation. currently each site has it’s own domain. i’d like to be able to keep them having their own domains, so what i’ve done within modx is setup a tree structure like this:

    ROOT
    -> Domain1 (1) (weblink to [~7~])
    ---> Home (7)
    ---> About (13)
    ---> Etc (14)
    -> Domain2 (2) (weblink to [~8~])
    ---> Home (8)
    ---> About (15)
    ---> Etc (16)
    -> Domain3 (3) (weblink to [~9~])
    ---> Home (9)
    -> Domain4 (4) (weblink to [~10~])
    ---> Home (10)
    -> Domain5 (5) (weblink to [~11~])
    ---> Home (11)
    -> Domain6 (6) (weblink to [~12~])
    ---> Home (12)

    so currently you go to the site like http://www.domain1.com, which sends you to the homepage of D1, so you get http://www.domain1.com/d1/home, then if you click the links say to domain 2 and domain 3 you get:

    http://www.domain1.com/d2/home
    http://www.domain1.com/d3/home

    so you can see the domain remains "domain1", but the "folder/directory" says "d2". what i’d like to do is write an htaccess chunk of code that says something like:

    * if you’re on "domain1.com/d2" redirect to "domain2.com/d2", if it says "domain1.com/d3" redirect to "domain3.com/d3", etc...
    * repeat for all other domains

    is there a pattern for this that i could use? it’d be great if it remembered where the person was trying to go as well, like if a user typed in "http://www.domain1.com/d3/company/about" they would be sent to "http://www.domain3.com/d3/company/about".
      • 27672
      • 168 Posts
      perhaps something like (in no particular coding syntax, just pseudo-code):

      if(part1 == ’domain1.com’ && part2 != ’/d1’){
      redirect to ’domain1.com/d1/home’;
      }else if(part1 == ’domain2.com’ && part2 != ’/d2’){
      redirect to ’domain2.com/d2/home’;
      }

      does that logic make sense? anyone know how exactly to write that in .htaccess?
        • 16610
        • 634 Posts
          Mikko Lammi, Owner at Maagit
          • 27672
          • 168 Posts
          that looks incredible. going to have to parse it later today. thanks a ton!