CodeIgniter Forums
Remove controller name for affiliate system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Remove controller name for affiliate system (/showthread.php?tid=38628)

Pages: 1 2


Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Mantero[/eluser]
I'm currently adding affiliate system to my site.

currently my affiliate agent can use URL like this:

http://www.mysite.com/affiliate/mantero

'mantero' is affiliate id which is unique and dynamic

my problem is how I'm able to remove the controller name in URL and they can just use like this:

http://www.mysite.com/mantero

My appologies if this has been asked before..but I really could'nt find any solution for my exact problem

thanks in advanced


Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Mantero[/eluser]
just to add I also have another controller..so is it possible to use routes? how if so..

thanks


Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Rok Biderman[/eluser]
If you add this into config/routes.php it should do the trick:

Quote:$route['mantero'] = 'affiliate/mantero';



Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Mantero[/eluser]
[quote author="Coccodrillo" date="1297709044"]If you add this into config/routes.php it should do the trick:

Quote:$route['mantero'] = 'affiliate/mantero';
[/quote]

how I'm supposed to do that..that 'mantero' is the ID which is unique and dynamic..it just an example...

if I have thousands of ID I don't think I can make a routes for all that...


Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Rok Biderman[/eluser]
in that case:

Code:
$route[‘(:any)’] = ‘affiliate/$1’;



Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]cideveloper[/eluser]
[quote author="Coccodrillo" date="1297714846"]in that case:

Code:
$route[‘(:any)’] = ‘affiliate/$1’;
[/quote]

That will not work since he has other controllers. Thus his other controllers will be routed to "affiliate/controller_name". I dont really have a solution but I just know this did not work for me. If I am wrong please let me know so I can fix my code.

Maybe hooks are a better solution?


Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Mantero[/eluser]
[quote author="cideveloper" date="1297716662"][quote author="Coccodrillo" date="1297714846"]in that case:

Code:
$route[‘(:any)’] = ‘affiliate/$1’;
[/quote]

That will not work since he has other controllers. Thus his other controllers will be routed to "affiliate/controller_name". I dont really have a solution but I just know this did not work for me. If I am wrong please let me know so I can fix my code.

Maybe hooks are a better solution?[/quote]

yes, the problem is because I have other controller as well..

can we make exception for the routes?

I mean if I have Controller1,Controller2,Controller3, except all these controller will goes to affiliate controller...are this possible?


Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Mantero[/eluser]
I mean like this

Code:
$route['^(?!controller1|controller2|controller3).*'] = "affiliate/$0";



Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Rok Biderman[/eluser]
Why wouldn't this work?

Code:
$route['otherroute/(:any)'] = "othercontroller/$1";
$route["(:any)"] = "affiliates/$1";



Remove controller name for affiliate system - El Forum - 02-14-2011

[eluser]Mantero[/eluser]
[quote author="Coccodrillo" date="1297718408"]Why wouldn't this work?

Code:
$route['otherroute/(:any)'] = "othercontroller/$1";
$route["(:any)"] = "affiliates/$1";
[/quote]

$route['otherroute/(:any)'] = "othercontroller/$1";<--that mean I have to define the route for each of my controller?