Welcome Guest, Not a member yet? Register   Sign In
[solved] Need help with a simple routing problem
#1

[eluser]Unknown[/eluser]
Edit: nevermind, ill just catch everything with

Code:
$route['(:any)'] = "site";
$route['default_controller'] = "site";

And use uri->segment to see what pages have to be displayed.


---

Hi everyone, I've got a (i hope) simple question for you, why does the following code not work?


My site.php in the controller directory:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {

        function __construct() {
                parent::__construct();
        }

        public function index() {
                echo "index";
        }

        public function subpage() {
                echo "subpage";
        }

        public function newspost() {
                echo "newspost";
        }
}
?>

My routes file:

Code:
$route[':any/:any/:num'] = "site/newspost";
$route[':any/:any'] = "site/subpage";
$route['default_controller'] = "site";
$route['404_override'] = '';

If i try to go to localhost/mysite/ I see "index", but when i go to localhost/mysite/whatever i get a page not found (a page generated by apache, not CI), but shouldnt it say "subpage"?


Messages In This Thread
[solved] Need help with a simple routing problem - by El Forum - 08-10-2011, 10:38 AM
[solved] Need help with a simple routing problem - by El Forum - 08-10-2011, 02:33 PM
[solved] Need help with a simple routing problem - by El Forum - 08-10-2011, 03:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB