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.