Jump to content

Affiliate tracking project problem


jumpinjacq

Recommended Posts

Hi everyone,

 

I'm developing an affiliate tracking process and after a lot of thought, I was wondering if someone might be able suggest if I'm on the right track.  I'm trying to get away from the usual ...?id=135845 type of links.  I was thinking about two possibilities:

 

1.  (I don't know if this is possible), but to generate a subdomain with php at the time an affiliate signs up and then track them by extracting the subdomain to identify the affiliate, or

 

2.  Somehow, maybe using a mod rewrite, using the affiliate username at the end of a url, ex. www.website.com/username  , you can see that there is no extension, but when a person comes to that url, it will display the contents of www.website.com and I'd extract the username 'username' from the url and query the database to identify the affiliate.

 

Any thoughts on how this can be done?

Link to comment
Share on other sites

You can do wildcard subdomain handling with apache -- but why?  That hardly seems justified for an affiliate program.  Then there is the /username.  That is really just a spin on id=affiliateID.  You use a rewrite rule to pick off that first directory and route it to index.php?affiliate=affiliatename

 

 

Link to comment
Share on other sites

Hi Gizmola,

 

Thanks for the quick reply.  I kinda figured it would be a mod rewrite.  I've looked at about about ten different sites and gone into tutorials to try to figure it out, but haven't been successful in understanding how to do this.  Do you know where I can find some example code?  Or even a tutorial that will get me up to speed?

Link to comment
Share on other sites

If you implement a script that takes the GET parameter example I provided, then a mod_rewrite rule should not be an issue.  It depends a good deal on what routing your site already uses, and whether or not you already have rewrite rules. 

 

Consider this example:

 

www.yoursite/some_affiliate_name

 

Has the issue that "some affiliate name" could literally be anything, and could interfere with valid urls you have to existing resources.  There is no good reason not to use instead:

 

www.yoursite.com/affiliate/affiliate_name

 

Your rewrite rule for this might be something like this:

 

rewriteRule ^affiliate/([a-z0-9]+)$  affiliate.php?affiliate=$1 [NC, L]

 

That rule will route www.yoursite.com/affiliate/gizmola to the affiliate.php script and pass affiliate=gizmola to it as a get parameter.

 

Google mod_rewrite, mod_rewrite tutorial etc. for articles you can read.  Mod_rewrite rules support and typically require regular expressions, and you may be lost without doing some research into those if you don't already know what they do.

 

 

 

Link to comment
Share on other sites

That all  makes sense, thank you.

 

I tried the code that you provided and I'm getting a 500 internal error.  The only rewrites I have I've provided below:

 

RewriteEngine on

DirectoryIndex index.shtml index.html index.php

RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$

RewriteRule ^/?$ "http\:\/\/www\.mywebsite\.com\/otherfile\/" [R=301,L]

 

Would these be causing a problem?  The 500 internal error is across the site, no url works.

Link to comment
Share on other sites

Looks like the httpd.conf file needs to be modified to allow what I'm trying to do, but I can't find it, most likely because I'm on shared hosting.  But there is the option to add an Apache Handler in Panelbox UI, maybe that is where I need to set this up?  I'll contact their admin and see what I can find out.  Any thoughts on this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.