Welcome Guest, Not a member yet? Register   Sign In
URI Routing Questions/Possibilities
#1

[eluser]RellimTtocs80[/eluser]
Good day all,

I have a question about URI routing and to see if I could get something to work.

What I am trying to do is have a URI that looks like this

Code:
/campusName/departmentName/index

Where the campusName and departmentName are dynamic which should point to the call class "campus" and then the function "department" with the names as params like this

Code:
/campus/department/campusName/departmentName

However, I will also want other static controllers names such as "users", "students", etc. So, is it possible to configure the routes to look at the class and invoke the static class if it is a valid controller, then invoke the route in the config file if there is no valid controller for the first segment in the URI?

Thanks in advance
-Scott
#2

[eluser]RellimTtocs80[/eluser]
After trying some different things, I have found that adding the route within config/routes.php as
Code:
$route['(:any)/(:any)'] = "campus/departments/$1/$2";
will allow you to still use other controllers that exist. May be it has something to do with the .htaccess file that I have the following in

Code:
RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

where if the file is a valid file, there will be no rerouting/rewriting
#3

[eluser]RellimTtocs80[/eluser]
Actually that didn't work in all cases, I had to change the (:any) to Regular Expression and now it all works well




Theme © iAndrew 2016 - Forum software by © MyBB