Welcome Guest, Not a member yet? Register   Sign In
URL Forwarding and CodeIgniter
#1

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

[eluser]Jelmer[/eluser]
Check routes in the documentation: http://ellislab.com/codeigniter/user-gui...uting.html
#3

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

[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';




Theme © iAndrew 2016 - Forum software by © MyBB