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

    I have just launched a new MODx site and transferred across all of the content from my old site.

    I have made a number of improvements to the structure, but I still have some incoming links to the old structure that need to be maintained for now. The domain name itself is the same.

    Here is an example of the old vs. new structure:

    Old site: www.mysite.com/about-us/contact-us New site: www.mysite.com/contact-us

    What is the best way to deal with this, so that both search engines and people accessing old links will reach the correct page?

    Thanks,
    Matt
      • 18206
      • 59 Posts
      Try adding a rewrite rule to your .htaccess file, something along the lines of.. (untested)
      RewriteRule ^/[^/]+/(.*) http://www.mysite.com/$1 [R=301,L]
        • 20557
        • 43 Posts
        Thanks for your reply.

        I’m now not sure if my .htaccess file is working at all. Friendly URLs are working OK, but none of the redirect entries I have tried seem to work - including the one posted above.

        My hosting provider is running Apache on Windows - could this have something to do with it?
          • 20557
          • 43 Posts
          After some further investigation, one of the admins at my hosting provider told me the following:


          The redirects you were trying to do were conflicting with the SEF rewrites so I’ve used another method which will work just fine with your .htaccess file:

          RewriteRule ^about-us/contact-us http://www.new-site.com/contact-us.html [R=301,L]

          Just thought I would post this, in case anyone else has the same problem as me.

          Thanks,
          Matt
            • 18206
            • 59 Posts
            In that case the problem was most likely that you put this new rewrite after the friendly ones: it never got tested.
            Do you only need to redirect one page? In that case the rewrite you were given will do suffuciently and is faster than a regex-match. smiley
              • 20557
              • 43 Posts
              Thanks Mar.

              I did have some other redirects to do, but I have managed to do most of them using the same method.

              Matt