We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31227
    • 198 Posts
    grr.. the latets beta available in the beta section..:(
      Pure MODx sites
      Viriko.ru & Viriko.com - Multilingual and running on 1 MODx
      • 10449
      • 956 Posts
      hmm... I’m using this plugin, but if my old URLs have paths, e.g. news/article-123, it doesn’t work. I get 404s instead.
        • 8004
        • 39 Posts
        Quote from: ganeshXL at Sep 30, 2008, 04:54 AM

        hmm... I’m using this plugin, but if my old URLs have paths, e.g. news/article-123, it doesn’t work. I get 404s instead.
        i have some problem, anybody know how2fix that ?
          www.ekg-uralsnab.ru - экг 5а, колеса крановые шкивы, металлообработка
          • 5727
          • 160 Posts
          Quote from: DreamCast at Apr 15, 2009, 02:55 AM

          Quote from: ganeshXL at Sep 30, 2008, 04:54 AM

          hmm... I’m using this plugin, but if my old URLs have paths, e.g. news/article-123, it doesn’t work. I get 404s instead.
          i have some problem, anybody know how2fix that ?

          I modified the code to allow that, I only tested a couple URLs but it should work. Let me know if there’s any bug. It’s also more optimized.

          /*####
          #
          #   Name: NG!Redirect
          #   Version: 0.0.2
          #   Author: Stefan Bruggmann - http://www.ng-projects.ch
              @modified: Olivier B. Deland
          #   Date: Apr 10, 2008 13:12 CET
          #
          # Latest Version: http://modxcms.com/...
          # In use on Site: http://www.ng-studio.ch
          #
          ####
          #
          #
          # Usage:
          # Enter your old Site-Names and the new static ones or dynamic id's to the following array like..
          #
          # Example:
          # $sites = array(
          #   'The-Old-URL-Without-Extension' => 6,
          #   'Another-Old-URL' => 'A-New-Hard-Link'
          # );
          #
          ####
          */
          
          $sites = array(
              'shop/products/thing.html' => 'shop/products/newthing.html',
              'index.html' => 1
          );
          
          $e = &$modx->Event;
          switch ($e->name) {
              case "OnPageNotFound":
                  $requestedURL = $modx->virtualDir.'/'.$modx->documentIdentifier;
                  if (isset($sites[$requestedURL])) {
                      if( is_numeric($sites[$requestedURL]) ){
                          $url = $modx->makeUrl($sites[$requestedURL],'','','full');
                      }
                      else{
                          $url = $sites[$requestedURL];
                      }
                      $this->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently');
                      exit;
                  }
                  break;
                  
              default :
                  return; // stop here
          }
          
            Olivier Deland
            Montreal, Canada - Web Developer
            • 21438
            • 10 Posts
            Yes, that sub-directories fix works for me. It even works if I add extensions on old URLS (eg: ’subdir/oldpage.html’ => ’newdir/newpage’). Assuming it’s stable, could you release this new code to the repository? I was wondering why it wasn’t redirecting properly before!