Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist (/showthread.php?tid=16849) |
Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 03-18-2009 [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. Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 03-18-2009 [eluser]pistolPete[/eluser] I'd recommend routing: routes.php Code: // first route (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. Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 03-18-2009 [eluser]Azureus[/eluser] Got it thanks Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 04-10-2009 [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? Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 04-10-2009 [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? Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 04-10-2009 [eluser]Azureus[/eluser] The problem is I have many controllers and it's tedious to reroute every new controller. Replacing http://www.example.com/class with http://www.example.com/unknown($salt) if a particular class doesn't exist - El Forum - 04-11-2009 [eluser]pistolPete[/eluser] Did you have a look at this helper function? forums/viewthread/51740/#261261 |