Macrura Posted May 23, 2013 Share Posted May 23, 2013 Hi - I'm finalizing a new ecommerce site, and the old site was around for a really long time, i guess it used coldfusion or something like that. The old URLs look like this: /store_item_detail.cfm?item_ID=20&cart_ID=1027539129526 All of those same products are in the new processwire site, and i imported the item_ID fields, so i have access to those; first i tried creating a new page called store_item_detail.cfm with the idea that i could get the item_ID as a get variable and then redirect to the new page; but since the old system doesn't use trailing slashes, i'm kind of stuck on this one... all i really need to do is get access to that item_ID without PW throwing a 404 and then i can do the redirect... TIA! Link to comment Share on other sites More sharing options...
diogo Posted May 23, 2013 Share Posted May 23, 2013 Maybe you could use the .htaccess to redirect /store_item_detail.cfm to /store-item-detail, or any other page you want. Don't ask me, I don't know how to do it Link to comment Share on other sites More sharing options...
horst Posted May 23, 2013 Share Posted May 23, 2013 (edited) first i tried creating a new page called store_item_detail.cfm with the idea that i could get the item_ID as a get variable and then redirect to the new page; but since the old system doesn't use trailing slashes, i'm kind of stuck on this one... all i really need to do is get access to that item_ID without PW throwing a 404 and then i can do the redirect... Don't know if I understand your needs right: Under Setup -> Templates -> URLs is the option should page URLs end with a slash? If 'Yes', pages using this template will always have URLs that end with a trailing slash '/'. And if the page is loaded from a URL without the slash, it will be redirected to it. If you select 'No', the non-slashed version will be enforced instead. Note that this setting does not enforce this behavior on URL segments or page numbers, only actual page URLs. If you don't have a preference, it is recommended that you leave this set to 'Yes'. Or maybe you can redirect the old pageURL to the new one via .htaccess EDIT: I think redirect can be done like this: Redirect 301 /store_item_detail.cfm http://example.com/new_pw_page_for_that/ Another way would be to use ModRewrite, but with Redirect 301 (permanent) you also tell google and other crawlers that they can update their cache with the new URL. Edited May 23, 2013 by horst 4 Link to comment Share on other sites More sharing options...
Macrura Posted May 23, 2013 Author Share Posted May 23, 2013 hey thanks horst - i didn't know you could not have slashes on a per template basis; that should solve this, i'll report back tomorrow if i get it all working! ok got it working!... this is the template that the store_item_detail.cfm page is using: <?php if($input->get->item_ID) { $pid = $sanitizer->selectorValue($input->get->item_ID); } $fwd = $pages->get("template=product-legacy, legacy_item_id=$pid")->url; if($fwd) { $session->redirect($fwd); } else { $session->redirect('/default-page/'); } 2 Link to comment Share on other sites More sharing options...
ryan Posted May 25, 2013 Share Posted May 25, 2013 Sounds like you found a good solution there. I just wanted to mention one alternative that I've used before too, just for the sake of discussion. You can add this to your .htaccess file: AddType application/x-httpd-php .cfm That will make files ending with ".cfm" get run by PHP. Then you could create this file: /store_item_detail.cfm require("./index.php"); // bootstrap ProcessWire $itemID = (int) wire('input')->get->item_ID; if($itemID) { $item = wire('pages')->get("template=product-legacy, legacy_item_id=$itemID"); if($item->id) { // now you can either render the page… echo $item->render(); // …or if you prefer, redirect to it: wire('session')->redirect($item->url); } else { echo "Unknown item ID"; } } else { echo "No item ID specified"; } There you have it–ProcessWire powering ColdFusion scripts. 4 Link to comment Share on other sites More sharing options...
Macrura Posted May 26, 2013 Author Share Posted May 26, 2013 Hi Ryan, very nice solution, and this would be ideal if a client needed to retain original cfm URLs, which i guess could be really important in some scenarios; great to know this can be done. I'll be posting this site tomorrow in the showcase, it's the biggest site i've done yet with PW. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now