We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36493
    • 64 Posts
    Hello and thanks in advance,

    I have a two linked sites that I would like to manage from the one backend.

    Unfortunately I’m stuck on a shared server. it’s a plesk setup with domain aliases. Would it be posible to setup

    a domain A with an alias of domain B

    but requests for one domain points to the A context and the other points to the B context.

    Sorry I think I have read something related to this question before but I have not been able to find the post.

    Any help or suggestions would be wonderful.

    Cheers
      |
      • 34193
      • 330 Posts
      I’m sure the answer to this is yes. In some of the early docs I’m sure I saw some code that could be used used to setup a plugin, that checked the domain name and changed to the correct context. I can’t find it just now, but i’m sure it’s out there somewhere.
        • 36493
        • 64 Posts
        Many thanks peteedley

        - the plugin was the way to go, docs here:
        http://rtfm.modx.com/display/revolution20/Using+One+Gateway+Plugin+to+Manage+Multiple+Domains


        All working well now (apart from the login script)

        Cheers,
          |
          • 36493
          • 64 Posts
          Well I had to change the method used to accommodate multiple domains and contexts in order to fix the Login issue
          (see this thread for the issue: http://modxcms.com/forums/index.php/topic,54611.msg315371/topicseen.html#msg315371)

          I’m now using a new index.php and config.core.php in a new folder(newContextFolder) for each extra domain/context.

          I have also adapted my /.htaccess file to redirect requests for http://domain.tld to http://domain.tld/newContextFolder/

          Unfortunately I’m not great with rewrite rules and I’m now redirecting any request to a page other then / to my error page.

          my addition to /.htaccess
          
          # Only apply to URLs on this domain
          RewriteCond %{HTTP_HOST} ^(www.)?domain.tld$
          
          # Only apply to URLs that aren't already under folder.
          #RewriteCond %{REQUEST_URI} !^/folder/
          
          # Don't apply to URLs that go to existing files or folders.
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          
          # Rewrite all those to insert /folder.
          RewriteRule ^(.*)$ /folder/$1
          
          # Also redirect the root folder.
          RewriteCond %{HTTP_HOST} ^(www.)?domain.tld$
          RewriteRule ^(.*)$ _/index.php?q=$1 [L,QSA]
          
          


          Is there any one who has a better solution or knows how to do rewrites who could help me?
            |
            • 36493
            • 64 Posts
            Ok After fumbling around with rewite rules i have success rolleyes

            I don’t think this is the best way to do it but it’s working so if any one want’s to do some thing similar then you may use my .htaccess as a guide:
            
            SetEnv PHPRC /var/www/vhosts/domain1.tld/httpdocs
            # setEnv for suphp
            
            # MODx supports Friendly URLs via this .htaccess file. You must serve web
            # pages via Apache with mod_rewrite to use this functionality, and you must
            # change the file name from ht.access to .htaccess.
            #
            # Make sure RewriteBase points to the directory where you installed MODx.
            # E.g., "/modx" if your installation is in a "modx" subdirectory.
            #
            # You may choose to make your URLs non-case-sensitive by adding a NC directive
            # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
            
            
            
            RewriteEngine On
            RewriteBase /
            
            
            #redirect domainalias2.tld -> primary domain2.tld
            RewriteCond %{HTTP_HOST} .
            RewriteCond %{HTTP_HOST} ^(www.)?domainalias2\.tld [NC]
            RewriteRule (.*) http://domain2.tld$1 [R=301,L]
            
            
            #redirect domainalias1.tld -> primary domain1.tld
            RewriteCond %{HTTP_HOST} .
            RewriteCond %{HTTP_HOST} ^(www.)?domainalias1\.tld [NC]
            RewriteRule (.*) http://domain1.tld$1 [R=301,L]
            
            
            # these rules below are for redirecting domain2.tld to the correct '/folder/index.php' where the context2 is set
            # Only apply to URLs on this domain
            RewriteCond %{HTTP_HOST} ^(www.)?domain2.tld$
            
            # Only apply to URLs that aren't already under folder.
            RewriteCond %{REQUEST_URI} !^/folder/
            
            # Don't apply to URLs that go to existing files or folders.
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            
            # Rewrite all those to insert /folder.
            RewriteRule ^$ /folder/ [L]
            
            # Don't apply to URLs that go to existing files.
            RewriteCond %{REQUEST_FILENAME} !-f
            
            # Also redirect the root folder.
            RewriteCond %{HTTP_HOST} ^(www.)?domain2.tld$
            RewriteRule ^(folder)?(.*)$ folder/index.php?q=$2 [L,QSA]
            
            
            
            
            
            
            
            
            
            
            
            # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent 
            # https://www.domain.com when your cert only allows https://secure.domain.com
            #RewriteCond %{SERVER_PORT} !^443
            #RewriteRule (.*) https://example-domain-please-change.com.com/$1 [R=301,L]
            
            
            
            # The Friendly URLs part
            #only apply to domain1.tld
            RewriteCond %{HTTP_HOST} ^(www.)?domain1.tld$
            # Don't apply to URLs that go to existing files or folders.
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
            
            
            
            # Make sure .htc files are served with the proper MIME type, which is critical # for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
            
            #AddType text/x-component .htc
            
            
            
            # If your server is not already configured as such, the following directive
            # should be uncommented in order to set PHP's register_globals option to OFF.
            # This closes a major security hole that is abused by most XSS (cross-site
            # scripting) attacks. For more information: http://php.net/register_globals
            #
            # To verify that this option has been set to OFF, open the Manager and choose
            # Reports -> System Info and then click the phpinfo() link. Do a Find on Page
            # for "register_globals". The Local Value should be OFF. If the Master Value
            # is OFF then you do not need this directive here.
            #
            # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
            #
            # Your server does not allow PHP directives to be set via .htaccess. In that
            # case you must make this change in your php.ini file instead. If you are
            # using a commercial web host, contact the administrators for assistance in
            # doing this. Not all servers allow local php.ini files, and they should
            # include all PHP configurations (not just this one), or you will effectively
            # reset everything to PHP defaults. Consult www.php.net for more detailed
            # information about setting PHP directives.
            
            #php_flag register_globals Off
            
            
            
            # For servers that support output compression, you should pick up a bit of
            # speed by un-commenting the following lines.
            
            #php_flag zlib.output_compression On
            #php_value zlib.output_compression_level 5
            
            
            
            # The following directives stop screen flicker in IE on CSS rollovers. If
            # needed, un-comment the following rules. When they're in place, you may have
            # to do a force-refresh in order to see changes in your designs.
            
            #ExpiresActive On
            #ExpiresByType image/gif A2592000
            #ExpiresByType image/jpeg A2592000
            #ExpiresByType image/png A2592000
            #BrowserMatch "MSIE" brokenvary=1
            #BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
            #BrowserMatch "Opera" !brokenvary
            #SetEnvIf brokenvary 1 force-no-vary
            
            
            # up memory and ex. time
            php_value memory_limit 128M
            php_value max_execution_time 120
            
            



            Many thanks to all that have helped me.
            The modx community rocks!
              |