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

[eluser]lefrog[/eluser]
I cannot seem to get my routing to work as per the user guide:

$route['page/:any'] = "page";

I want anything with the first segment equal to page and second segemnt equal to anything to go to page

It works if the url is:

http://localhost:9017/index.php/page/

but if I add a second segment i.e

http://localhost:9017/index.php/page/test/

I get a 404

Am I using the routes config correctly?
#2

[eluser]coolfactor[/eluser]
Do you have an index() function in your Page controller?
#3

[eluser]lefrog[/eluser]
Yes my controller is


Code:
<?php

    /**
    *
    */
    class Page extends Controller
    {
        function Page()
        {
            parent::Controller();
        }
        
        function index()
        {
            die('this is a test');
        }
        
    }
    


?>
#4

[eluser]Unknown[/eluser]
Have you some other routes rules in your routes.php ?

I tested your example on my machine and it worked.
#5

[eluser]lefrog[/eluser]
Thanks for responding!
Weird that, these are my route rules:

Code:
$route['page/:any'] = "page";
$route['rss'] = 'feed';
$route['scaffolding_trigger'] = "";

Like I say it works if I type

http://localhost:9017/index.php/page

or

http://localhost:9017/index.php/page/index

but if I type

http://localhost:9017/index.php/page/gallery

I get a 404. Is there something I'm missing here.

Can I route an url with two segments to a just the class 'page'.
#6

[eluser]coolfactor[/eluser]
You should put your custom routes *after* those that were in the file already.

"default_controller" and "scaffolding_trigger" should be first, followed by your own. There's a bug in the Router library.
#7

[eluser]lefrog[/eluser]
That works a treat cool!

Thanks for the help as I was beginning to get a headache.

Code Igniter is a sweet framework, I'm 'mostly' enjoying using it and its making most things a breeze!!!




Theme © iAndrew 2016 - Forum software by © MyBB