Welcome Guest, Not a member yet? Register   Sign In
Remove controller name for affiliate system
#1

[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
#2

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

thanks
#3

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

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

[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...
#5

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

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

[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?
#7

[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?
#8

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

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

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

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

[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?




Theme © iAndrew 2016 - Forum software by © MyBB