CodeIgniter Forums
Routing question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Routing question (/thread-15423.html)



Routing question - El Forum - 02-04-2009

[eluser]pepijn744[/eluser]
Hi,

I'm entering the final stage of the project I'm working on right now and I want to add a routing feature.

Say, my site is www.site.com. I want to redirect all of the first URI segment, except for /register, /contact, /aboutus, to /profile/show/$1. Is something like that possible? I'm already using the mod_rewrite, so no www.site.com/index.php/(.*) anymore.

Thanks in advance.


Routing question - El Forum - 02-04-2009

[eluser]richthegeek[/eluser]
routes are executed in the order that they are listed, and matching one stops the execution of the rest.

As such, having your routes looking something like this:
Code:
$routes['register'] = '/users/register';
$routes['contact'] = '/controller/contact';
$routes['profile'] = '/users/profile';
$routes['(:any)'] = '/show/$1';

Should sort you out.


Routing question - El Forum - 02-04-2009

[eluser]pepijn744[/eluser]
Thanks! It works now. I have to correct you on the variable name, it is $route instead of $routes.


Routing question - El Forum - 02-04-2009

[eluser]richthegeek[/eluser]
Sorry,haven't used routes in a while so was writing from memory


Routing question - El Forum - 02-04-2009

[eluser]pepijn744[/eluser]
You helped me out so no problem Smile

I have another question... I'm adding an extern forum in /forum/, can i make an exception for this folder so it doesn't go to CodeIgniter? I think I'll have to change .htaccess for this. Can anybody help me out? I'm not so good at this area.


Routing question - El Forum - 02-04-2009

[eluser]richthegeek[/eluser]
the htaccess only redirects if there is no physical location at that adress... Which is why your /CSS and/or /assets folder work


Routing question - El Forum - 02-04-2009

[eluser]pepijn744[/eluser]
Oops I see! Thank you, I will not bother you anymore.