Link to home
Start Free TrialLog in
Avatar of cycledude
cycledudeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

codeigniter routing issues?

Hi

Just starting out with codeigniter and have a couple of problems...

I have a simple controller, called public_site.php

in the routes.php I have set the default_controller to public_site

the controller has 2 methods

index

about

1: if I browse to ‘www.myurl.com/ci’ the index page displays fine

2: if I browse to ‘www.myurl.com/ci/index.php/about’ i get a 404 page not found

3: however if i browse to ‘www.myurl.com/ci/index.php/public_site/about’ it displays the page


also I am having problems with the location of the css.. in scenario 1 above the page displays with css correct, however with scenario 3, the page displays with no css… how do you keep track of the css location if you are using a template header and footer?

Thanks

cycledude
Avatar of frisoft
frisoft
Flag of Slovakia image

Your first example is basically the call of www.myurl.com/ci/index.php/public_site/index
if You want the ‘www.myurl.com/ci/index.php/about  url to work too, you should define route, for example in \application\config\routes.php add a line:
$route['about'] = 'public_site/about'

For css, js and other assets (and in fact for any url) i recommend use of the full path, see helper site_url() for the base url of your site.
Avatar of cycledude

ASKER

@frisoft

thanks for the help, adding the about route sorted it...

I am a little confused as I thought that was what the 'default_controller' was for...

so that anything in the url after index.php would be a method in the default_controller?

maybe I got the wrong impression?
ASKER CERTIFIED SOLUTION
Avatar of frisoft
frisoft
Flag of Slovakia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help, it was much appreciated.