Welcome Guest, Not a member yet? Register   Sign In
Routing
#1

[eluser]xenon-dev[/eluser]
Hello. I've been trying to build my first project with CI, but I'm having a little problem...I need to make a part of this project the default one, but can't get it right. In routes.php there is this line:

Code:
$route['default_controller'] = "portfolio/home";

All good (or should be). But, when loading the page(localhost/CodeIgniter/), it throws up this error:

Code:
404 Page Not Found

The page you requested was not found.

The application structure is as follows:

Code:
controllers
    portfolio
        home.php

And I still can't figure out WHY it shows a 'page not found' error, though it looks ok to me. The .htaccess file:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|user_guide|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

I can't understand what's wrong, please help me. Thanks.
#2

[eluser]esra[/eluser]
Is your $config['base_url'] setting in config.php set to your site url?
#3

[eluser]coolfactor[/eluser]
"default_controller" should just be the name of your controller, not both a controller and a method.
#4

[eluser]esra[/eluser]
[quote author="coolfactor" date="1188793134"]"default_controller" should just be the name of your controller, not both a controller and a method.[/quote]

He is trying to get controller subfolders to work which I don't use. But, there are a lot of threads elsewhere about that topic.

I think the problem is that the default controller code is hard coded in Codeigniter.php or Common.php and that subfolders are not considered by that code for the default controller (not sure about this without looking at the framework code). Thus, the default controller may have to reside in controllers/ and the corresponding view may need to reside in views/, but any other controllers could be stored in the subfolders defined in routes.php. I don't recall all of the details of this mess.
#5

[eluser]xenon-dev[/eluser]
[quote author="esra" date="1188791981"]Is your $config['base_url'] setting in config.php set to your site url?[/quote]

Yes, it is. I'll try to put the main file of the application directly into the controllers/ directory, so I don't encounter any more problems (works fine that way). However, the CI devs should take a look at that, because I'm a webdev, and what if I'll get to the point where I would've been building 100 CI projects? I'll just end up with 100 files in controllers/ and 100 subfolders for each website. Not cool - couldn't tell which is which. I could look into the CI's files and modify the behaviour, but then, it would become a custom CI installation - again, not that cool. I might easily forget that I modified the 'x' file.

Thanks alot for the help.
#6

[eluser]coolfactor[/eluser]
[quote author="xenon-dev" date="1188818437"]...what if I'll get to the point where I would've been building 100 CI projects? I'll just end up with 100 files in controllers/ and 100 subfolders for each website. Not cool - couldn't tell which is which.[/quote]

Each CI application is distinct, so 100 CI projects would not result in 100 default controllers in a single folder.

Quote:I could look into the CI's files and modify the behaviour, but then, it would become a custom CI installation - again, not that cool. I might easily forget that I modified the 'x' file.

CodeIgniter is modifiable by extending the built-in libraries. This lets you change its behavior without modifying the distribution one bit. The customized libraries are loaded for you automatically. No extra work once they are installed in the applications/libraries/ directory.
#7

[eluser]xenon-dev[/eluser]
[quote author="coolfactor" date="1188820412"]CodeIgniter is modifiable by extending the built-in libraries. This lets you change its behavior without modifying the distribution one bit. The customized libraries are loaded for you automatically. No extra work once they are installed in the applications/libraries/ directory.[/quote]

I'll review that part and see what suits me best. Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB