We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I am setting up a site which needs different contexts for different subdirs. I set up everything according the XRouting (also treid ContextRouter) instructions, but it's failing. Everything is redirected to resource 1.

    What am I missing?

    base_url /
    cultureKey en
    http_host domain.nl
    site_start 1
    site_url https://www.domain.nl/

    base_url /pk/
    cultureKey pk
    http_host domain.nl
    site_start 4
    site_url https://www.domain.nl/pk/ [ed. note: handjes last edited this post 6 years ago.]
      • 54171
      • 7 Posts
      To have two sites running on the same installation, you need to :
      The setting can be made directly from the left site bar: right mouse button- > "edit", then we get into the context setting. Or another option: basic settings - > contexts - > select the context that we created –> right mouse button –> edit –> end up on the same page. Go to the "context settings"tab. Here you need to create four key parameters responsible for the functionality of the context.

      1 the – base_url parameter responsible for the base path. Write the base_url, and set its value is "slash" / ("root").

      The following parameter is site_url (using underscores!). This full website url with the given Protocol, that is, writing http, let's say we have a GMT website, and create it as a subdomain of your main domain: http://msk.project.loc/ in the end necessarily need to put a slash.



      The following parameter is an http host. Write "http_host" with the underscore. Here we specify the same subdomain, but without taking into account the Protocol (i.e., write "msk.project.lock").

      And the last parameter-optional, but desirable – is the start page of the context – site_start. It is set by resource ID. In the "resources" tab, you can see that the MSK resource has an ID of 8, so in the "Value" field, put the eight so that "msk" becomes the main page of the context. Save all 4 parameters and their settings.

      Next, you need to install a component that will intercept user requests and give them the appropriate context. Go to apps - > installer - > download add-on. There are two main additions that perform the function we need – contexRouter and X-Routing, load both. They perform virtually one and the same work with small differences, so questioning can be any of them. So, installed the system, and no more additional settings with this context is not necessary, it already intercepts requests and gives the appropriate context.

      It remains to configure the web server correctly. Since we created a subdomain to the main domain, we find the file structure of the web server, looking for our end-of-directory .loc and create another msk.project.loc, that is, create an empty folder, it is a subdomain.

      Restart the web service to define a new subdomain. Then go to settings or go to the tab alias to link our subdomain MSC, msk.project.loc to the primary domain, that is, the project domain.loc. Add the alias to be persistent, the server is restarted, Hooray! All basic settings are made. Go back to the admin panel, run the page and look: now in the address bar starts the site on the subdomain MSK.project.loc-and here is opened the main page site " greetings, Moscow." The same decoration, the same patterns are used. This way you can create an unlimited number of contexts and implement a multilingual or MultiSite project structure
      • Ok, thanks for the general explanation. But what am I doing wrong? Maybe you could help my situation?
          • 17301
          • 932 Posts
          It looks correct based on what you've posted. Have you given permissions and access to the new context for the usergroup (or annonymous) so they can access it?
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • Yes I added the context to the Anonymous group.

            The context is not even showing it's own error page.
            • Different tutorials are saying different things about the base_url and http_host:

              Should theu always only contain the '/', or should they include the subdir ( /subdir/ )? [ed. note: handjes last edited this post 6 years ago.]
                • 17301
                • 932 Posts
                no '/' on the http_host but yes on the base_url and site_url, what you have is setup correctly. What access policy does anonymous have?
                  ■ email: [email protected] | ■ website: https://alienbuild.uk

                  The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                • Anonymous has Load only in every context.
                    • 17301
                    • 932 Posts
                    Sounds correct. Do you have anything custom in your .htaccess or are you using the one that comes with MODX?
                      ■ email: [email protected] | ■ website: https://alienbuild.uk

                      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                    • Nothing special in the htaccess. It's the default htaccess file.

                      Strange thing is: I am working on two sites, and both are having this problem. I configured them just as I did in the past with other sites.

                      It must be one small thing I am missing.

                      Too bad, MODX and addons still come with poor tutorials (I am not a developer).