Welcome Guest, Not a member yet? Register   Sign In
Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist
#1

[eluser]Azureus[/eluser]
CodeIgniter expects a class after my domain name http://www.example.com/(class). The problem is when my program generates a random key(salt) I want to replace the class name with that salt EX. $salt = "a1b2c3d4" now I want http://www.example.com/$salt. I want http://www.example.com/$salt to redirected(maybe with .htaccess) to http://www.example.com/class/function/$salt without changing the url maybe with curl. So I want http://www.example.com/$salt to show whatever http://www.example.com/class/function/$salt is showing. I can't afford to use http://www.example.com/class/function/$salt directly because of its length so I must use http://www.example.com/$salt. My first thought was about using .htaccess file then using URI routing then using a hook. Can anyone give me any suggestions on how to do this and what to use? Thanks.
#2

[eluser]pistolPete[/eluser]
I'd recommend routing:

routes.php
Code:
// first route
$route['default_controller'] = 'your_default_controller';
// put all of your controller routes here or see (1)
(...)

// last route
$route['(:any)'] = 'salt_controller/function/$1';

(1): http://ellislab.com/forums/viewreply/540633/

Using this method you have to explicitly route every controller and put these routes before the :any route.
#3

[eluser]Azureus[/eluser]
Got it thanks Smile
#4

[eluser]Azureus[/eluser]
To pistolPete's post... Is there a way I don't have to rout my controllers? Is there a way to check if the controller exists first then if not send a unique to a known controller?
#5

[eluser]pistolPete[/eluser]
Quote:Is there a way to check if the controller exists first then if not send a unique to a known controller?
That is exactly what routing does.

Why do you want something else than routing?
#6

[eluser]Azureus[/eluser]
The problem is I have many controllers and it's tedious to reroute every new controller.
#7

[eluser]pistolPete[/eluser]
Did you have a look at this helper function?
forums/viewthread/51740/#261261




Theme © iAndrew 2016 - Forum software by © MyBB