![]() |
How do you remove the controller from the URL? - 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: How do you remove the controller from the URL? (/showthread.php?tid=17929) Pages:
1
2
|
How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]learning_php[/eluser] Hi, My url's are currently : http://localhost/wedding-site/homepage/X but I want them to look like this: http://localhost/wedding-site/X. I have looked at the routes.php file but I am unsure what I need to do? Thanks How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]Dam1an[/eluser] Code: $route['homepage/(:any)'] = "$1"; That should do it How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]learning_php[/eluser] Hi, After putting that in the routes I get a 404 error Thanks How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]Dam1an[/eluser] Sorry, my bad, got it the wrong way round, it should be Code: $route['(:any)'] = "homepage/$1"; How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]learning_php[/eluser] Hi, I am still getting http://localhost/wedding-site/homepage/X Thanks How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]Dam1an[/eluser] When do you get that? When you go to the root of the site? Click a link, or even when you manually put the URL to http://localhost/wedding-site/X? How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]learning_php[/eluser] Hi, It seems that as my link was Code: <?= anchor('homepage/info','Information');?> Code: <?= anchor('/info','Information');?> Thanks for the help How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]Dam1an[/eluser] That would make sense, I thought you where getting the homepage in there when you just went to the homepage lol And I don't think it makes a difference, but you don't need the '/' for the start fof your anchor How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]learning_php[/eluser] Thanks for that. But I have another controller that now gets a 404 error is there any reason for this? I dont link to this but type in the url. How do you remove the controller from the URL? - El Forum - 04-20-2009 [eluser]Dam1an[/eluser] Ah, should have seen that coming Basically, it matches the rule in the route file, so its trying to route it to homepage/fuction, and I'm guessing you don't have a function with that name in the homepage controller? Are you trying to access the function in the second controller with or without the controller name in the URL? You'll either have to manually specify each route, or consolidate the controllers into one Or use some clever Regex (which you'd have to look up) |