We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26422
    • 107 Posts
    scottishbullet Reply #1, 16 years ago
    Hi, I’ve created a new context to handle a domain and have set up the context settings as indicated in the attached screen. Now how do I get the domain to point to the context? Do I have to set something up at the registrar?

    Thanks for any help on this.
    Crawford
      Crawford Paul

      Bridgecourt Web Design - Proudly using ModX CMS
      Serving Welland, Niagara, Ontario, Canada and the world!
      http://www.bridgecourt.com
      • 10152
      • 156 Posts
      French Fries Reply #2, 16 years ago
      Hi,if you are using apache2, add your hosts :
      raf:~# vi /etc/hosts
      127.0.0.1	localhost
      
      192.168.1.2     mysite.dev
      192.168.1.2     fr.mysite.dev
      192.168.1.2     de.mysite.dev
      192.168.1.2     es.mysite.dev
      192.168.1.2     nl.mysite.dev
      [...]
      

      and then add virtual hosts at the end of apache2.conf:
      raf:~# vi /etc/apache2/apache2.conf
      [..]
      <VirtualHost mysite.dev>
               ServerName raf
               DocumentRoot /var/www/dev/mysite
      </VirtualHost>
      
      <VirtualHost fr.mysite.dev>
               ServerName fr.mysite.dev
               DocumentRoot /var/www/dev/mysite/subdoms/fr
      </VirtualHost>
      
      <VirtualHost de.mysite.dev>
               ServerName de.mysite.dev
               DocumentRoot /var/www/dev/mysite/subdoms/de
      </VirtualHost>
      
      <VirtualHost es.mysite.dev>
               ServerName es.mysite.dev
               DocumentRoot /var/www/dev/mysite/subdoms/es
      </VirtualHost>
      
      <VirtualHost nl.mysite.dev>
               ServerName nl.mysite.dev
               DocumentRoot /var/www/dev/mysite/subdoms/nl
      </VirtualHost>
      

      create the "subdoms" folder with config files insides and restart apache.
      Now http://fr.mysite.dev/ should point to the fr context.
      I am not a professionnal of apache nor modx, correct me if something is wrong.
        • 26422
        • 107 Posts
        scottishbullet Reply #3, 16 years ago
        Thanks for your reply. I’ll give it a shot and let you know how it goes. Since my sites are on a shared server I will need to ask support to make those changes. If anyone can verify this or has another way of doing this on a shared server, please post.

        Thanks!!
        C.
          Crawford Paul

          Bridgecourt Web Design - Proudly using ModX CMS
          Serving Welland, Niagara, Ontario, Canada and the world!
          http://www.bridgecourt.com
          • 1441
          • 61 Posts
          Hey!

          I’ve been doing this quite a bit. I found this wiki article helpful...

          http://rtfm.modx.com/display/revolution20/Using+One+Gateway+Plugin+to+Manage+Multiple+Domains

          Basically - take code like below, and drop it in a new plugin
          <?php
          switch ($modx->getOption('http_host')) {
             case 'beta.example.org:80':
             case 'beta.example.org':
                // if the http_host is of a specific domain, switch the context
                $modx->switchContext('beta');
                break;
             default:
                // by default, don't do anything
                break;
          }
          ?>
          

          Make sure to check ’OnHandleRequest’ in the System Events tab of the plugin.

          Using shared hosting (like cPanel) as I do - I just point all my subdomains, and domains at the root of my account, and I copy & paste the code above one after another for each context - making changes where necessary.

          Works like a charm for me! (and better yet - no code to speak of otherwise - and no host-side alterations)