We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38415 ☆ A M B ☆
    • 70 Posts
    Hi,

    I'm currently updating an existing 2.2.0 install to the 2.2.2 nightly (of yesterday).


    What I experience since 2.2.1 is that furls with RewriteRules for GET-parameters redirect (with 301) to the strict furl.

    Example:

    You have a resource with the url
    domain.com/gallery/
    and an snippet inside that displays an image based on an "img" GET-parameter.
    and you have a RewriteRule in you htaccess file like this:
    RewriteRule ^gallery/([^/]*)/$ gallery/?&img=$1 [QSA,L]


    Now you should be able (and until 2.2.0 it works) to request
    domain/gallery/2412/

    and this url should stay in the browser and there should be no redirect.

    Unfortunately since 2.2.1 MODX generates a 301 redirect to the exact resource url and adds the get parameter:
    domain.com/gallery/?img=2412



    What has changed in 2.2.1 and is there a way to disable it? I really don't like this behavior and don't want GET-parameters to be displayed.

    This question has been answered by opengeek. See the first response.

      chsmedien - Digital Marketing Agency
      MODX Professional & Ambassador

      http://chsmedien.com | http://twitter.com/christianseel
      • 31246 ☆ A M B ☆
      • 428 Posts
      it seems to me the right to create a plug-in and give the event OnPageNotFound
      Then catch your URL
      example:
      if ($modx->event->name == 'OnPageNotFound'){
        $arrayURI = explode('/',$_SERVER['REQUEST_URI']);
        $albumId = explode('-',$arrayURI[2]);
        if($arrayURI[1] == 'gallery' && $albumId[0] == 'album'){
          $_REQUEST['img'] = $albumId[1];
          $modx->sendForward(83); // 83  - is the id of the resource gallery
        }
        return '';
      }
        Valentin Rasulov - Industrial design (Hobbies - Web Development)
        Development not standard projects on CMF MODx Revolution.
        Small sample of extensions
        • 38415 ☆ A M B ☆
        • 70 Posts
        Mh... This won't work because of

        1st: I don't think OnPageNotFound will be triggered, cause the page is found, right?

        2nd: It's a quiet complex website. With some more pages that uses GET-parameter like this (also dynamic created resources). So I would have to create Plugins vor a lot of resources. That can't work.
          chsmedien - Digital Marketing Agency
          MODX Professional & Ambassador

          http://chsmedien.com | http://twitter.com/christianseel
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: christianseel at May 01, 2012, 02:34 AM
          Hi,
          RewriteRule ^gallery/([^/]*)/$ gallery/?&img=$1 [QSA,L]

          Can you try adjusting your RewriteRule to the following?
          RewriteRule ^gallery/([^/]*)/$ gallery/?img=$1 [QSA,L]

            • 38415 ☆ A M B ☆
            • 70 Posts
            Quote from: opengeek at May 01, 2012, 08:08 AM
            Can you try adjusting your RewriteRule to the following?
            RewriteRule ^gallery/([^/]*)/$ gallery/?img=$1 [QSA,L]

            Tried it. No change. Still a 301.
              chsmedien - Digital Marketing Agency
              MODX Professional & Ambassador

              http://chsmedien.com | http://twitter.com/christianseel
              • 31246 ☆ A M B ☆
              • 428 Posts
              I have worked in such a record. htaccess
              Options +FollowSymlinks
              RewriteRule ^gallery/([^/]*)/$ /index.php?q=gallery/?img=$1 [N]
              

                Valentin Rasulov - Industrial design (Hobbies - Web Development)
                Development not standard projects on CMF MODx Revolution.
                Small sample of extensions
                • 31246 ☆ A M B ☆
                • 428 Posts
                Quote from: christianseel at May 01, 2012, 07:56 AM
                Mh... This won't work because of

                1st: I don't think OnPageNotFound will be triggered, cause the page is found, right?

                2nd: It's a quiet complex website. With some more pages that uses GET-parameter like this (also dynamic created resources). So I would have to create Plugins vor a lot of resources. That can't work.
                1) If you have a query in the form of domain/gallery/2412 / it works OnPageNotFound, why do you think that the resource will be found?
                Earlier I gave an example, but it is not accurate for your actions.
                What is needed:
                if ($modx->event->name == 'OnPageNotFound'){
                  $arrayURI = explode('/',$_SERVER['REQUEST_URI']);
                  if($arrayURI[1] == 'gallery' ){
                    $_REQUEST['img'] = $arrayURI[2];
                    $modx->sendForward(83); // 83  - is the id of the resource gallery
                  }
                  return '';
                }

                not tested, should work
                2) did not quite understand, you have URL can be domain/gallery/2412/page/ ?
                  Valentin Rasulov - Industrial design (Hobbies - Web Development)
                  Development not standard projects on CMF MODx Revolution.
                  Small sample of extensions
                  • 38415 ☆ A M B ☆
                  • 70 Posts
                  Quote from: valikras at May 01, 2012, 08:24 AM
                  I have worked in such a record. htaccess
                  Options +FollowSymlinks
                  RewriteRule ^gallery/([^/]*)/$ /index.php?q=gallery/?img=$1 [N]
                  

                  Also produces a 301.

                  I think this is issue might be produced by the new feature request_method_strict... But i have no idea how to test against it.
                    chsmedien - Digital Marketing Agency
                    MODX Professional & Ambassador

                    http://chsmedien.com | http://twitter.com/christianseel
                    • 38415 ☆ A M B ☆
                    • 70 Posts
                    Artdevue,

                    I tested you plugin. As I expected the OnPageNotFound event is not fired.

                    ...the right resource is found! But modx generates a 301 redirect to the exact uri of that resource and adds the get-parameters with ?i=....
                      chsmedien - Digital Marketing Agency
                      MODX Professional & Ambassador

                      http://chsmedien.com | http://twitter.com/christianseel
                      • 34109
                      • 119 Posts
                      According to the docs, you can specify the response code when using sendForward, so you should be able to set this to 200.

                      http://rtfm.modx.com/display/revolution20/modX.sendForward

                        Studio Republic
                        http://www.studiorepublic.com
                        0845 226 3205
                        @christodhunter