CodeIgniter Forums
problem with controllers under sub folder / sub directory - 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: problem with controllers under sub folder / sub directory (/showthread.php?tid=14348)



problem with controllers under sub folder / sub directory - El Forum - 12-30-2008

[eluser]$@!ful[/eluser]
As my given directory structure I set my default controller in router configuration as:
$route['default_controller'] = "visitor/home";

So, when I browse http://www.domain.com then it lodes controller/visitor/home.php

But when I browse http://www.domain.com/visitor or http://www.domain.com/visitor/home then it shows 404 error.

I need to load home controller using the following url:
http://www.domain.com/visitor
http://www.domain.com/visitor/home

Whether home.php is a default controller or not.

Thanks


problem with controllers under sub folder / sub directory - El Forum - 12-30-2008

[eluser]Phil Sturgeon[/eluser]
You cant have a controller in a sub-domain, or a method as the default route. This is a bug thats been around a long time, hopefully it will be fixed soon.

One option would be to use .htaccess to redirect.


problem with controllers under sub folder / sub directory - El Forum - 12-30-2008

[eluser]simshaun[/eluser]
[quote author="pyromaniac" date="1230673227"]You cant have a controller in a sub-domain, or a method as the default route. This is a bug thats been around a long time, hopefully it will be fixed soon.

One option would be to use .htaccess to redirect.[/quote]

You mean sub-folder right?


problem with controllers under sub folder / sub directory - El Forum - 12-30-2008

[eluser]$@!ful[/eluser]
[quote author="simshaun" date="1230674340"][quote author="pyromaniac" date="1230673227"]You cant have a controller in a sub-domain, or a method as the default route. This is a bug thats been around a long time, hopefully it will be fixed soon.

One option would be to use .htaccess to redirect.[/quote]

You mean sub-folder right?[/quote]

But what does it mean?


problem with controllers under sub folder / sub directory - El Forum - 12-30-2008

[eluser]simshaun[/eluser]
You can have controllers within a subfolder is what it means.
Say you have admin/homepage.php inside your controllers folder.

Assuming you are using .htaccess to remove index.php, you can access that controller by going to
http://www.website.com/admin/homepage

Now, you can set "default_controller" to "homepage" or "admin/homepage". You shouldn't set it to "admin/homepage", and I'll explain why.

By setting it to "homepage", you can now access the controller by going to
http://www.website.com/admin/homepage -OR- http://www.website.com/admin/

By setting it to "admin/homepage", you can access it by going to
http://www.website.com/, but NOT http://www.website.com/admin/.
When accessing http://www.website.com/admin/, CI is essentially trying to load http://www.website.com/admin/admin/homepage


problem with controllers under sub folder / sub directory - El Forum - 12-31-2008

[eluser]Phil Sturgeon[/eluser]
Ha yes sorry I meant sub-directory Big Grin