Check

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: 4 Responses

4 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!!

Got something to say?





*