We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7966
    • 90 Posts
    I am in stage of moving one of existing sites to modx. I plan to use one modx installation for a couple of non-related websites.

    Websites are on a shared-linux hosting.

    - MODx Revolution 2.0.3-pl version (Upgraded to MODx Revolution 2.0.4-pl2 now, just in case it might help but no difference)

    - I forwarded the first website document root to modx installation folder.

    - Created a new web context, and move all documents from "web" to "new context"

    - Added the following settings for "new context"

    --- base_url --> /
    --- http_host --> www.newwebsite.com
    --- site_start --> 117
    --- site_url --> http://www.newwebsite.com/


    - created a plugin with following code, and activated "OnHandleRequest" event
    <?php
    switch ($modx->getOption('http_host')) {  
       case 'www.newwebsite.com:80':  
       case 'www.newwebsite.com':  
          // if the http_host is of a specific domain, switch the context  
          $modx->switchContext('newcontext');  
          break;  
       default:  
          // by default, don't do anything  
          break;  
    }




    - htaccess file is below
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /modx
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /modx/index.php?q=$1 [L,QSA]
    
    
    


    - friendly url’s are active



    If I browse the home page, as www.newwebsite.com I can see the content, (with some snippets not working).

    If I browse on any other page, "Internal Server Error" error is displayed.

    If I remove the friendly url’s , then website works without any problem.

    Do we need to set anything else to make modx work for multiple sites with friendly urls and one gateway plugin.

    Thanks


      • 36592
      • 970 Posts
      From your .htaccess setting, the home page must be www.newwebsite.com/modx .
      If your web server setting points your site to /modx, your .htaccess file must be...
      Options +FollowSymlinks
      RewriteEngine On
      RewriteBase /
      
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      
        • 7966
        • 90 Posts
        Thanks. Actually, modx is on another domain, this is a just generic domain, which has no content but modx.

        so other websites, like "newwebsite.com" points to this modx installation path, and uses the htaccess of the generic domain.

        I don’t know if I need to add anything to htaccess file for each website.

          • 7966
          • 90 Posts
          still looking for a solution but no success. there is no errors in error log. I also added the web context settings for default "web" context but didn’t help.

          another weird thing is that when the home page of newwebsite.com is previewed, it is directed to home page of default "web" context which is the "modxdomain.com/modx/". All other pages gives internal server error.

          is there anyone managed to make this plugin work with multiple websites and friendly urls?