CodeIgniter Forums
URL Forwarding and CodeIgniter - 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: URL Forwarding and CodeIgniter (/showthread.php?tid=10126)



URL Forwarding and CodeIgniter - El Forum - 07-19-2008

[eluser]Eric Cope[/eluser]
I need to forward a web address like this:
Code:
http://homesite.com/some_text
to this
Code:
http://homesite.com/CI_class/CI_function/more_data

At first I thought to use .htaccess rewrites, however the list of possible values of some_text will be growing/changing/shrinking. That means I would need to regenerate .htaccess every time the list of some_text changes, which does not seem appealing. Does anyone have any ideas?


URL Forwarding and CodeIgniter - El Forum - 07-19-2008

[eluser]Jelmer[/eluser]
Check routes in the documentation: http://ellislab.com/codeigniter/user-guide/general/routing.html


URL Forwarding and CodeIgniter - El Forum - 07-19-2008

[eluser]Eric Cope[/eluser]
It looks like some regular expressions and back references will do it. Additionally, I should route my classes above the regular expressions so they don't get incorrectly translated.

Code:
$route['^([a-zA-Z0-9\_\-]+)$'] = "class_to_process_route/$1";

That should match only letters, numbers. underscores and dashes. Can someone double check me?


URL Forwarding and CodeIgniter - El Forum - 07-19-2008

[eluser]Jelmer[/eluser]
if you want to route everything except for a couple of controllers you're right although I'd choose over the regex:

Code:
$route[':any'] = 'controller';