site.com/variable INSTEAD OF site.com/controller/function/variable??? |
[eluser]Guest[/eluser]
Hi again all! I currently have my site working like this... site.com/video/variable/variable/etc it's working well, but is there anyway to remove the "video" controller from the url path? i have tried changing routes.php and setting this: $route['default_controller'] = "video"; And that will load the index function in the controller. But to then start adding variables to the url, you still need to put the controller name back in. I would really like to have this: site.com/variable/variable/etc Maybe a slight problem though, is that i would also still need to access other controllers if their name exists. So if a user typed: site.com/funny/free <-- that would load the video controller and variables. But if the user typed: site.com/join <-- i would like it to load the join controller, and see that exists, and should not be used as a variable in the video controller. Thanks so much for all the help i've been getting. This is a great forum :-) Regards,
[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...uting.html You need to add more routes than the default one. For example: Code: $route['staff/edit/:num'] = "admin/edit_staff/$1"; When the user accesses staff/edit/3, CI will call the admin controller, edit_staff() function, and pass 3 to that function.
[eluser]Kosonome[/eluser]
Code: $string = 'controller_name1|controller_name2|controller_name3'; Not sure if this regex is correct by the way.
[eluser]tomcode[/eluser]
in the config/routes file : Code: $route['default_controller'] = "welcome"; in the controller/welcome.php: Code: function _remap($first_var)
[eluser]Guest[/eluser]
wow, the routes.php file lets you do much more then i thought -- its kind of like the rewrite of a htaccess file (which i can never get to work :-) i have "almost" got my site working with the following code: Code: $route['members'] = "members"; This almost works great, if the code is not right, if someone can please explain how to improve it - that would be amazing. The real problem with the above is the ajax route. One of my javascript files "posts" a username to be checked to a controller called ajax.php for example -- in the js file, it would be "post" Joe Blogs to: site.com/ajax/functionname And it works perfect until i use this route line: Code: $route['(:any)'] = "welcome/$1"; Then the post no longer works between the javascript and the php page. If i remove it again, it works. I have tried making a route to exclude the ajax getting caught in the :any rule (i've commented it out above), but it doesnt work. Any help would be amazing again! Thanks for all the help guys :-)
[eluser]tomcode[/eluser]
The code should work. Take out all the code ouf the controllers, leave just an identifying echo and test the addresses directly in Your browser. You're surely have a bug somewhere.
[eluser]Guest[/eluser]
Ah, I needed to use this: Code: $route['ajax'] = "ajax"; That little $1 made all the difference :-) Thanks everyone for the help! |
Welcome Guest, Not a member yet? Register Sign In |