We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44920
    • 48 Posts
    Hi,

    I have a multilanguage website with multiple contexts. Recently there was SSL certificate installed on the server to make access to manager more secure. So now the site's back-end and also front-end are accessible via both http and https schemes.

    For each context I had specified
    site_url = http://www.mysite.com/
    OR e.g.
    site_url = http://www.mysite.com/de/
    etc.
    


    As you can guess this hardcoded site_url caused some problems with https access. So I used the trick described here:
    http://stackoverflow.com/questions/21704388/configuring-modx-revolution-to-work-with-both-http-and-https
    to make site work under both schemes (http & https).

    [For lazy readers] In short - site_urls were changed to read:
    site_url = [[++url_scheme]]www.mysite.com/
    OR e.g.
    site_url = [[++url_scheme]]www.mysite.com/de/
    etc.

    which made work the most of the stuff where site_url get parsed.
    for the rest there is small snippet:
    $modx->config['site_url'] = $modx->config['url_scheme'] . substr($modx->config['site_url'], strlen('[[++url_scheme]]'));
    return '';

    which I call in each template.

    Above trick works in the most cases. However I found one where it does not work.
    I have a contact form using FormIt extra. And there is redirect hook which redirects to specified 'thank you page' once the form is processed.

    Because of makeUrl() calls from FormIt (with hardcoded scheme = 'full') my redirect after form processing ends up on:
    https://www.example.com/[[++url_scheme]]www.example.com/[[++url_scheme]]www.example.com/thank-you-page.html


    instead of

    https://www.example.com/thank-you-page.html


    Do you have similar experience and have maybe some workaround for situation like this? It can behave similarly with different extras which use some redirecting or so.
    Thank you in advance [ed. note: smashingred last edited this post 12 years, 3 months ago.]
      MODX Revolution 2.2.8-pl (advanced)

      Extras:
      archivist 1.2.4 | Articles 1.7.1 | Babel 2.2.5 | getpage 1.2.3 | getresources 1.6.0 | quip 2.3.3 | SimpleSearch 1.6.1 | taglister 1.1.7 | TinyMCE 4.3.3 | Wayfinder 2.3.3

      PHP Version 5.6.20-0
      MySQL Version 5.5.31
      • 44920
      • 48 Posts
      Succeeded to resolve the issue.

      What helped was to create new hook which does something like:
      $modx->config['site_url'] = $modx->config['url_scheme'] . substr($modx->config['site_url'], strlen('[[++url_scheme]]'));


      and then add this hook right before redirect hook in FormIt call
        MODX Revolution 2.2.8-pl (advanced)

        Extras:
        archivist 1.2.4 | Articles 1.7.1 | Babel 2.2.5 | getpage 1.2.3 | getresources 1.6.0 | quip 2.3.3 | SimpleSearch 1.6.1 | taglister 1.1.7 | TinyMCE 4.3.3 | Wayfinder 2.3.3

        PHP Version 5.6.20-0
        MySQL Version 5.5.31
        • 44920
        • 48 Posts
        However described solution brings a lot of problems in areas not covered by templating e.g. in Quip notification emails on new comment(s) there's a link to the blog article that comment relates to; "View" button in manager; links to related blog entries in comments list etc. - all these contain untranslated string "[[++url_scheme]]"

        Do you know some more elegant solution how to make the site work under both protocols - https & http?

        Thank you in advance
          MODX Revolution 2.2.8-pl (advanced)

          Extras:
          archivist 1.2.4 | Articles 1.7.1 | Babel 2.2.5 | getpage 1.2.3 | getresources 1.6.0 | quip 2.3.3 | SimpleSearch 1.6.1 | taglister 1.1.7 | TinyMCE 4.3.3 | Wayfinder 2.3.3

          PHP Version 5.6.20-0
          MySQL Version 5.5.31