We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47795
    • 16 Posts
    Hello All

    I have been recently doing a lot of re-organization on my website, and through this a lot of pages have been moved.

    Looking through my Google Webmaster logs - a few websites out there are linking back to these now dead pages.

    I tried setting up a redirect for this link (dead)
    http://www.computer-legacy.com/items/misc/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html
    To point to this link (alive)
    http://www.computer-legacy.com/items/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html

    This is my code in my .htaccess file:

    RewriteRule items/misc/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html items/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html [R=301,L]


    Yet the redirect does not work.

    I have tried a traditional 301 redirect but that too doesn't work.

    I have also tried using the redirector plug-in, that worked - until I realised it was redirecting ALL my dead links to the target page.

    Any ideas, I would really like to get this working.

    Thanks
    Dan
    Computer-Legacy.com
      • 20371
      • 58 Posts
      I use the redirector plugin a fair bit. It's handy that it will redirect to the new resource number even if the url changes.. otherwise you'd have to change all your redirects in .htaccess if you change something again in future.

      Anyhow, it's weird that it was redirecting all dead links to your chosen page.

      Are you sure you didn't have your error_page setting set to the same page you were trying to redirect pages to from the plugin?
        • 47795
        • 16 Posts
        Hi Mr5o1.

        Could you give me some examples of how to set up the Pattern for my links in Redirector?

        I would assume the reason that all my dead links were being redirected was a mistake in my Syntax (I am not familiar with Regular Expressions at all).

        And no my error_page setting is my homepage.

        Thanks
        Dan
          • 20371
          • 58 Posts
          Umm.. I haven't been using any regex, does the plugin actually say you can??

          your pattern would be:

          items/misc/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html


          and then target is simply

          [[~21]]


          where 21 is the resource id of the page you're redirecting to.

          You're sure there's nothing funky left in your .htaccess right ?
            • 47795
            • 16 Posts
            Okay, I've done that - the redirect works, but its now redirecting any incorrect URL.

            For example try

            http://computer-legacy.com/items/pagedoesntexist.html

            It will always go to: http://computer-legacy.com/items/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html

            The rule is set up so:

            Pattern = items/misc/tutorials-and-guides/2013/how-to-install-microsoft-sql-2000-client-tools-on-windows-7.html
            Target = [[~211]]

            Regarding my .htacess - I have removed any redirects from that - still the same. I do also have friendly URL's on - if that makes any difference.

            I will continue to work at this, and see if I can fix it.

            Thanks
            Dan
              • 47795
              • 16 Posts
              Quick update:

              I turned on the setting Track URI Updates (as I use URI's throughout my website), and then made one change.

              This successfully added a second rule. The problem is that any dead link (i.e. http://computer-legacy.com/items/pagedoesntexist.html) would then go to the target of that latest rule.

              Very strange.
                • 20371
                • 58 Posts
                Oh here you go..

                It's a Known Issue (with workaround).
                  • 47795
                  • 16 Posts
                  Hooray! It worked.


                  For those curious, it was this post that contained the fix
                  In your manager, click on Plugins ->redicector and remove these lines (starting at line 33):

                          if(empty($redirect) || !is_object($redirect)) {
                              $redirect = $modx->getObject('modRedirect', array(
                                  "('".$search."' REGEXP `modRedirect`.`pattern` OR '".$search."' REGEXP CONCAT('^', `modRedirect`.`pattern`, '$'))",
                                  "(`modRedirect`.`context_key` = '".$modx->context->get('key')."' OR `modRedirect`.`context_key` IS NULL OR `modRedirect`.`context_key` = '')",
                                  'active' => true,
                              ));
                          }

                  Thank-you so much for your assistance!

                  Board moderators can mark this as solved.