1

I am pretty new to Magento ... I just can't figure out what to search for I am developing a site with this very specific requirement...

I am setting up a customer referral program... there are a lot of extensions for that online. however, there is a trick to it...

most referral URL is like www.foo.com/refercode=bar (or something close to it)

and then the system knows what to do...

in my case, it has to be set up in this way... www.foo.com/bar

so now my question is how to redirect that bar to foo.com/customer/account/create/bar (or any other module to get the code and do the job) without it conflicting with the actual redirects that are being done for a mage to work normal....???

any comments would be appreciated or if there is a complete module or extension that will do that job

  • Will the /bar always be /bar or can it bee /foo or /bat or /baz??? – philwinkle Apr 15 '13 at 22:00
  • /bar is user generated... it could be anything... it's going to act like a username – Drmjo Apr 15 '13 at 22:47
  • What is to prevent /bar from being a perfectly valid url on your website? What happens if the user generates /about or /contact or /404??? – philwinkle Apr 15 '13 at 22:49
  • it is a valid url... bottom line i want to give the user "A" a URL foo.com/bat when clicked by user "B" it'll transfer them to the user sign up page with "bat" being the value i use to know who referred user "B" that's going to sign up right now... – Drmjo Apr 15 '13 at 22:55
  • 1
    I actually just built this functionality today literally for a referral program. My client also requested hostname.com/bar, but I just went with hostname.com/r/bar - it's a lot more straight forward to implement avoiding conflicts. You can just setup a rewrite rule to your custom controller. – kalenjordan Apr 15 '13 at 23:30
0

Using the method suggested by @kalenjordan I would use an htaccess rewrite:

RewriteRule ^/r/(.*)$ http://foo.com/customer/account/create/$1 [R=301,L]

This allows you to preserve your actual store's url without affiliates hijacking actual page names. Force/lock them in to using /r/ as the prefix for the redirect handle. I know this isn't ideal or an exact answer to your question but this is the preferred method for you to provide 'pretty' urls while still enabling affiliate marketing.

You will still need to handle the params encoding in customer/account/create.

To do that, you need to provide a rewrite in the following controller:

Mage_Customer_AccountController and rewrite the method public function createAction. Rewriting controllers has some caveats, and you may prefer to do this with preDispatch observers. Or, at least, that's my preferred method.

More information on mod_rewrite:

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

  • nice thank you... I gave up on it figured it can't be done the right way... might as well just use a module thats out already with some random generated reference code... – Drmjo Apr 16 '13 at 21:32
  • Please either enter your own answer and accept; or mark mine as accepted - we need more answered questions during this beta. – philwinkle May 16 '13 at 4:44
  • I will accept your answer as the best answer YET... however it doesn't resolve my issue as that extra parameter in the url... and the whole point was to not have that.... – Drmjo May 21 '13 at 17:49
  • Please do not feel pressure to accept based on the above poke. We've been advised not to prompt for accepts anymore. Feel free to unaccept and edit your original question to bump and allow someone else to answer. – philwinkle May 21 '13 at 18:57
  • you were the only one that took the time to answer... you should get the credit.:) – Drmjo May 22 '13 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.