Welcome Guest, Not a member yet? Register   Sign In
Cant get routes to work
#1

[eluser]joe2011uk[/eluser]
Hi folks

coding a site at the moment, currently not working. I am working on admin panel and when type http://mydomain.com/admin i get 404 not a ci 404 tho.
Routes:
Code:
$route['default_controller'] = "avc_home";
$route['scaffolding_trigger'] = "";
$route['admin'] = "admin/main";
Config:
Code:
$config['base_url']    = "http://www.mydomain.co.uk";


$config['index_page'] = "index.php";

$config['uri_protocol']    = "REQUEST_URI";

$config['url_suffix'] = "/";


$config['language']    = "english";

$config['charset'] = "UTF-8";


$config['enable_hooks'] = FALSE;

$config['subclass_prefix'] = 'MY_';

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger']     = 'c';
$config['function_trigger']     = 'm';
$config['directory_trigger']     = 'd'; // experimental not currently in use
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['cache_path'] = '/cache';
$config['encryption_key'] = "";
$config['sess_cookie_name']        = 'ci_session';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;
$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";
$config['global_xss_filtering'] = TRUE;
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';
main.php
Code:
<?php

class Main extends Controller {
    function __construct(){
        parent::Controller();
        $this->is_logged_in();
    }
    function index(){
        $data['main_content'] = 'admin_home';
        $this->load->view('includes/template', $data);    
    }
    function admin_home(){
        $data['main_content'] = 'admin_home';
        $this->load->view('includes/template', $data);
    }
    
    function is_logged_in(){
        $is_logged_in = $this->session->userdata('is_logged_in');
        if(!isset($is_logged_in) || $is_logged_in != true){
            $this->load->view('login_admin_form');
        }
    }
}
?>

index.php in root directory
Code:
error_reporting(E_ALL);
$system_folder = "system"; //is in root
$application_folder = "/application"; // is in root
if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}
define('EXT', '.php');
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('FCPATH', str_replace(SELF, '', __FILE__));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

my folder layout is
Code:
publichtml/
    application/
        config
        controller/ admin/main.php
        model/
        view/includes/ template file.php
        ...
     system/
     css/
     images/

Im really stuck its driving me mad lol

All help appreciated

Many Thanks

Joe
#2

[eluser]nevercode[/eluser]
if not CI 404 . I think it is a htaccess problem.
#3

[eluser]joe2011uk[/eluser]
i've not added a htaccess file because its on testing server should i add

Thanks
Joe
#4

[eluser]Twisted1919[/eluser]
http://mydomain.com/index.php/admin
#5

[eluser]joe2011uk[/eluser]
yeh it works if I go to http://www.mydomain.com/index.php/admin but i want it to be http://mydomain.com/admin

Thanks
Joe
#6

[eluser]Twisted1919[/eluser]
then use .htaccess . search the forum for more info .
#7

[eluser]joe2011uk[/eluser]
ok added .htaccess and going to hhp://mydomain.com/admin = 404 not CI


.htaccess
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

its in my root directory

toally lost

Thanks
Joe




Theme © iAndrew 2016 - Forum software by © MyBB