ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to 301 Redirect an old Coldfusion Page with a Query String.

May 03, 2011 10:06am

Subscribe [5]
  • #1 / May 03, 2011 10:06am

    Todd D.

    460 posts

    I’m finding it almost impossible to get an answer on this one, so I thought I would turn to the forum with the most geniuses. 😊

    I just rebuilt a site that formerly existed on ColdFusion.

    I want to do a 301 redirect with htaccess for pages that formerly had a coldfusion query string. The old server used CF and the new server uses PHP.

    For example…

    Take this

    <a href="http://www.example.com/product.cfm?SID=10&Product_ID=5">http://www.example.com/product.cfm?SID=10&Product_ID=5</a>

    and make it go to

    <a href="http://www.example.com/widget5/">http://www.example.com/widget5/</a>

    I thought this would be easy.  Any ideas?

  • #2 / May 16, 2011 7:06pm

    openmotive

    65 posts

    Where a query string is used, the 301 redirect solution for static pages will not work; you’ll need to use a rewrite solution. Using “page.php?id=13” as an example, here’s what you’ll need to use in your htaccess file:

    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^id=13$
    RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

    In the example above the id=13 should be replaced with the query string of the page you wish to redirect and the page.php with the name of your file prior to the query string.

  • #3 / May 16, 2011 9:03pm

    Todd D.

    460 posts

    Thanks for posting that. I had forgotten my post in here.

    I tried many combinations prior to your post. The method I finally found that worked was…

    RewriteCond %{QUERY_STRING} ^SID=10&Product_ID=25$
    RewriteRule product.cfm /my_product_page/$1? [R=301,L]

    Again, thanks for your post!

  • #4 / May 17, 2011 12:20pm

    openmotive

    65 posts

    That works!

    Hmmm. We can’t seem to get it to work more than once…i.e. when we string a few of these together to match multiple different query-string based urls it fails.

    Were u able to get multiple rewrites like this to work in the same .htaccess file?

  • #5 / May 17, 2011 12:35pm

    Todd D.

    460 posts

    Yes, I have several of these rules stacked with different query strings and it’s working great.

    Make sure to change the second line where product.cfm might be something different… like category.cfm or about.cfm or similar.

    Also, the order of your rewrite rules can make or break the result.

  • #6 / Jun 01, 2011 1:06am

    Spark Creative

    28 posts

    Hey there,

    I am having the same issue with a site that I moved to EE from Miva Merchant. Their pages consisted of this:

    http://mydomain.com/mm5/merchant.mvc?Screen=CTGY&Category_Code=CHEM

    Any ideas on how can I redirect these permanently to the new categories and pages? I have tried the solution outlined here, but with no success. The /mm5 crap is no longer being used in anyway. Any help would be greatly appreciated! Thanks a million!

    -Danielle

  • #7 / Jun 10, 2011 4:53pm

    Spark Creative

    28 posts

    Any ideas out there in EE land? 😊

  • #8 / Nov 23, 2011 12:13pm

    AlanSeptoff

    1 posts

    Todd:

    Could you say more about things that make/break this?

    Your solution would seem to fix EXACTLY my problem.  But I can’t get it to work.  I suspect it’s not playing nicely with the rest of the htaccess file.

    Thanks,
    Alan

  • #9 / Nov 25, 2011 8:42pm

    tbldevelopment

    2 posts

    Todd:

    Could you say more about things that make/break this?

    Your solution would seem to fix EXACTLY my problem.  But I can’t get it to work.  I suspect it’s not playing nicely with the rest of the htaccess file.

    Thanks,
    Alan

     

    http://tbldevelopmentfirm.com/  check it out here

     

  • #10 / Nov 25, 2011 8:42pm

    tbldevelopment

    2 posts

    Todd:

    Could you say more about things that make/break this?

    Your solution would seem to fix EXACTLY my problem.  But I can’t get it to work.  I suspect it’s not playing nicely with the rest of the htaccess file.

    Thanks,
    Alan


    http://tbldevelopmentfirm.com/services/ipad-development/
    http://tbldevelopmentfirm.com/  check it out here

     

  • #11 / Mar 17, 2015 8:21am

    padstow

    101 posts

    This post is ages old, but I stumbled across it after trying probably 40 other combinations of techniques from all over the Internet - THANK YOU, this is the only method that worked!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases