Welcome Guest, Not a member yet? Register   Sign In
problem with controllers under sub folder / sub directory
#1

[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
#2

[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.
#3

[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?
#4

[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?
#5

[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
#6

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




Theme © iAndrew 2016 - Forum software by © MyBB