Welcome Guest, Not a member yet? Register   Sign In
Help with simple routing please?
#1

Routing is my weak point, Im still not clear how it works although I read the docs many times. Anyhoo.

This is my .htaccess file
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|assets|woff|eot|img|css|js|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

This is my controller:
Code:
class Tlc extends CI_Controller
    public function view($page='index')
    {
        if ( ! file_exists(APPPATH.'/views/tlc/'.$page.'.php'))
        {
            // Whoops, we don't have a page for that!
            show_404();
        }
         else
         {
            $this->load->view('tlc/templates/header.php');
            $this->load->view('tlc/'.$page);  
            $this->load->view('tlc/templates/footer.php');  
        }

And this is my routes.php
Code:
$route['default_controller'] = "tlc/view";
$route['/([a-z]+)'] = "tlc/view/$1";
$route['404_override'] = '';

I have my view files in views/tlc folder.

When you go to main page deltadigital.ca - everything is fine, but when you click deltadigital.ca/about-us or other similar menu items it doesnt work. It only works with full url i.e.

http://deltadigital.ca/index.php/tlc/view/about-us
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply


Messages In This Thread
Help with simple routing please? - by lexxtoronto - 06-12-2015, 07:07 AM
RE: Help with simple routing please? - by roopunk - 06-12-2015, 07:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB