We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46718
    • 39 Posts
    I've recently migrated multiple sites into one large site and am dealing with redirecting all of the old URL's to the new pages while trying to keep everything SEO friendly and easy for the client to read the Google Analytics reports.

    After several attempts, I ended up landing on using the .htaccess file to write my redirects, however I came across an odd behavior.

    Say I have the following old URL's I am trying to redirect: (List 1)

    1. mydomain.com/about-us/
    2. mydomain.com/about-us/our-policies

    To: (List 2)

    1. mydomain.com/about/
    2. mydomain.com/about/policies

    I've written my redirects like so: (List 3)

    1. Redirect 301 /about-us http://mydomain.com/index.php?id=20
    2. Redirect 301 /about-us/our-policies http://mydomain.com/index.php?id=21

    The issue with this setup is two-fold:

    1. One, is the fact that I have to redirect to the id of the page which is messing up the Google Analytics reports, because we have to add the hits for index.php?id=21 to /about/policies to get our real page count.
    2. The second issue is that the multi-level part does not work. So, #2 in the redirect example above from list 3 does not work if #1 is in the .htaccess file. It adds it to the end of the URL after a question mark.

    Now, some of you may ask why I'm not writing my redirects as follows:
    Redirect 301 /about-us /about

    That's because when I do that I end up with a result something like this:
    mydomain.com/?/about-us

    Which does not properly resolve.

    To wrap up, my question is how do I achieve the goal of having both items from list 1 redirect to both items in list 2 making sure all levels of the URL redirect properly using alias paths?

    Let me know if you need any other explanation or examples.

    Thanks!
      • 46718
      • 39 Posts
      ping
        • 40706
        • 128 Posts
        I would advise you to use SEO Tab which builds automatically an old-url rewriting when renaming documents. And could also filled manually. Which is much more conformable for you and others, then writing everything into an htaccess


        I never had issues with the questionmark inside the url after redirecting with htaccess.
        But I would use mod_rewrite for the redirection, like this (freely written)

        RewriteRule ^about-us(/.*)?$ about$1 [R=301,L]