Welcome Guest, Not a member yet? Register   Sign In
URL segments with pure navigational purpose (no controller)
#1

[eluser]omgnoseat[/eluser]
Hello,

I have been searching alot of the forums and found alot of similiar topics, but I found them very hard to understand.

My situation:
Lets say we have a website with the following URL segement:
www.example.com/something

With codeigniter, "something" is a controller.

Now what I want is just to use "something" purely for navigational options. So I could use it in this way.
www.example.com/something/controller

It's probably very simple but I found the other topics very difficult to understand.
Thanks in advance.
#2

[eluser]steelaz[/eluser]
Just drop your CodeIgniter installation in "something" folder. Default setup would work like this - www.example.com/something/index.php/controller , then with .htaccess and some configuration changes you should be able to get rid of index.php and have www.example.com/something/controller
#3

[eluser]Buso[/eluser]
http://ellislab.com/codeigniter/user-gui...uting.html

i'm not sure if I understood what you want, but try this:

if you want to add 'something' to every route:
Code:
$route['something'] = $route['default_controller'];
$route['something/(:any)'] = '$1';

if you want to add 'something' to one controller:
Code:
$route['something/some_controller'] = 'some_controller';
$route['something/some_controller/(:any)'] = 'some_controller/$1';
#4

[eluser]omgnoseat[/eluser]
[quote author="steelaz" date="1277777815"]Just drop your CodeIgniter installation in "something" folder. Default setup would work like this - www.example.com/something/index.php/controller , then with .htaccess and some configuration changes you should be able to get rid of index.php and have www.example.com/something/controller[/quote]

Creating a folder was enough indeed, I had a namespace conflict using a folder with the same name as a controller when I tried earlier. Feel like an idiot now haha.
The next question would be if there would be any solution for this namespace conflict?

Thanks for the help and the quick replies!
#5

[eluser]pickupman[/eluser]
Buso has the correct solution otherwise you will end up with a bunch of directories with CI files are at least subfolders with each having a index.php from default CI webroot. The routes feature is awesome, once you start using it.

Example: Say you want to have admin code in each controller, to help modularize your code. You can use routes like
Code:
$route['admin/(:any)/(:any)'] = '$1/admin/$2';
$route['admin/(:any)'] = '$1/admin';

Now any url using example.com/admin/user will be sent to "user" controller and "admin" method. The third parameter will handle what action you can take in admin method.




Theme © iAndrew 2016 - Forum software by © MyBB