jumpinjacq Posted December 8, 2011 Share Posted December 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/ Share on other sites More sharing options...
gizmola Posted December 8, 2011 Share Posted December 8, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/#findComment-1295614 Share on other sites More sharing options...
jumpinjacq Posted December 8, 2011 Author Share Posted December 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/#findComment-1295615 Share on other sites More sharing options...
gizmola Posted December 8, 2011 Share Posted December 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/#findComment-1295628 Share on other sites More sharing options...
jumpinjacq Posted December 8, 2011 Author Share Posted December 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/#findComment-1295824 Share on other sites More sharing options...
jumpinjacq Posted December 8, 2011 Author Share Posted December 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/#findComment-1295892 Share on other sites More sharing options...
scootstah Posted December 8, 2011 Share Posted December 8, 2011 I really doubt you will have that kind of control over any shared hosting. You'll likely need a VPS for that. Quote Link to comment https://forums.phpfreaks.com/topic/252723-affiliate-tracking-project-problem/#findComment-1295896 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.