301 Redirects for Dynamic URLs to Static Pages with htaccess

By Ted B.

Setting up a comprehensive list of 301 redirects in htaccess when migrating a high traffic website to a new platform can be time consuming and tricky especially if you’re working with dynamic urls.

We were recently migrating an ecommerce store with several hundred dynamically generated pages from osCommerce to Magento. All of the pages on the new site are using keyword rich static urls so we had our hands full. For basic instructions on how to set up a dynamic to static url redirect in htaccess you can find a great article here: 301 Redirects for Dynamic URLs. But if you’ve got several hundred dynamic to static redirects you’re looking at an entire afternoon of copy and paste.

We created an excel spreadsheet so you can just copy in the full list of dynamic URLs from your original site and static URLs on your new site and it will output the exact code you need. Just copy and paste into your .htaccess file and you should be good to go.

Download the Tool Here: 301 Redirects from Dynamic to Static Generator.

If you’re having any problems make sure you have “RewriteEngine On” at the top of your .htaccess file. Please leave a comment to let me know if this helped you or if you ran into issues.

UPDATE 1: When you copy the redirects from the spreadsheet to your code editor, they may come with double quotation marks wrapping each condition/rule pair. You should use a hard replace to delete all of these before posting to your site.

UPDATE 2: The original tool linked above was created for use in creating server redirects for a website hosting with Bluehost. More recently I ran into the same issue needing to create bulk dynamic redirects for a website hosted with Rackspace. I’m not sure what the exact difference was in server configuration, but the original tool wasn’t working. I created a revised tool that can be downloaded at the link below. The condition query is the same except that [NC] was added meaning “no case” to accept regardless of capitalization. The first portion of the rewrite rule represents the exact match portion of the URL to be rewritten. The question mark ensures that the dynamic portion of the URL (after the question mark) will not be tacked on to the end of the URL.

Download the Revised Tool Here: 301 Redirects from Dynamic to Static Generator REVISED.

Comments: 12 Responses

12 Responses to “301 Redirects for Dynamic URLs to Static Pages with htaccess”

  1. blake h on October 2nd, 2011 2:38 am

    This was extremely helpful. Saved me hours of time. Thanks!

  2. mikycomputers on October 14th, 2011 4:01 am

    Hey Just wanted to say, it’s working!
    and it’s working if you want to direct dynamic link to another dynamic link!

    You saved me so much work!
    Thank you so much!

  3. Ted B. on October 17th, 2011 6:40 pm

    Milky computers, that’s great to hear it’s working for dynamic to dynamic as well. I had no idea.

  4. James Parsons on December 9th, 2011 11:51 am

    Was looking for something like this forever. Thank you so much, worked without a hitch. The excel document definitely makes doing a large inventory ten times easier.

    Thank you so much!!

  5. Chris Smith on January 21st, 2012 4:33 am

    Great resource, many thanks

  6. Nikolaj on January 25th, 2012 7:01 am

    Great for so urls but I can’t get it to work with dynamic to dynamic.

    I keeps adding %3f to the url.

    I need to redirect this one



    but it comes you as

    Any help?


  7. Fabio Basile on May 1st, 2012 9:42 am

    I tried this for my site, it’s hosted at NetworkSolutions on a Unix server. I tested my Bio page but it returns a 404 error, any ideas?

  8. Gagan Kharbanda on May 22nd, 2012 6:50 am

    Many thanks dude…
    you saved my lots and lots of time

  9. Gagan Kharbanda on May 23rd, 2012 1:36 am


    Im using your excel file and its working like miracle for me :)

    The other problem im facing is that i wanna go extension less, means a page without html or php visibility.

    Pls provide the solution for that too.

  10. Setting Up 301 Redirects for Dynamic URLs - seOverflow| seOverflow on May 29th, 2012 2:04 pm

    [...] with a link to an Excel spreadsheet he created that can do all the dirty work for your. Check out 301 Redirects from Dynamic to Static Generator on his [...]

  11. Ryan on September 16th, 2012 10:23 pm

    Thanks for doing another great mod, been wiiatng a while for something like this. Just added this to my site and everything seems to be good. I got more of my pages indexed than I did with my crappy software generated one.

  12. Juan Diego on September 24th, 2012 12:17 am


    This tool is amazing, but I can´t make it works:

    For example I have those URL´s
    to redirect to:

    The spreeadsheet don´t work in this case, can you help me with that?

    Thanks in advantage,


Got something to say?