Welcome Guest, Not a member yet? Register   Sign In
Help, Page Not found
#1

[eluser]the_unforgiven[/eluser]
Please help me I have created a new controller, with corresponding views and model pages but still when I navigate to the page http://localhost/mcd/admin/sym is show page not found.

See code below:

I really could do with some help on this not sure why this is happening but sure some of you more advanced can point it out str8 away.

Thanks in advance

Code:
<?php
session_start();
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Sym extends Controller
{
    function __construct()
    {
        parent::__construct();

        $this->load->helper('url');
        $this->load->model('Bikes');
        $this->config->load('mcd');
        
    }

    function index()
    {
        //Get list of bikes for the right column
        $data['bikes']=$this->Bikes->getAllBikes(15);//where manufacturer is sym (id=6)
        
        $controller = $this->uri->segment(1);
        
        //Get the default bike for the category
        $data['bike'] = $this->Bikes->getBike('default', $controller);
        $data['current_slug'] = $data['bike']['url_slug'];
        $data['accessories'] = $this->Bikes->getBikeAccessories('default', $controller);
        $data['enquiry'] = 'enquiry';
        
        $this->load->view($controller, $data);
    }
    
    function getBike() //default action for a page
    {
        $controller = $this->uri->segment(1);
        $url_slug = $this->uri->segment(2);
        
        //Get list of bikes for the right column
        $data['bikes']=$this->Bikes->getAllBikes(15);
        
        //get the bike indicated by the url_slug
        $data['bike'] = $this->Bikes->getBike($url_slug);
        $data['accessories'] = $this->Bikes->getBikeAccessories($url_slug);
        $data['current_slug'] = $url_slug;
        
        $this->load->view($controller, $data);
    }
    
    function getRawDetails() //for reloading the details pane by ajax ONLY
    {    
        //get the bike indicated by the url_slug
        $url_slug = $this->uri->segment(2);
        $data['bike'] = $this->Bikes->getBike($url_slug);
        
        $this->load->view('bike/_details', $data);
    }
    
    function getRawAccessories()  //for reloading the accessories pane by ajax ONLY
    {
        //get the bike indicated by the url_slug
        $url_slug = $this->uri->segment(2);
        
        $data['accessories'] = $this->Bikes->getBikeAccessories($url_slug);
        
        $this->load->view('bike/_accessories', $data);
    }
    
    function getRawQuote() //for reloading the quote pane by ajax ONLY
    {
        //get the bike indicated by the url_slug
        $url_slug = $this->uri->segment(2);
        
        $data['bike'] = $this->Bikes->getBike($url_slug);
        
        $this->load->view('bike/_quote', $data);
    }
}
?>
#2

[eluser]eggzy[/eluser]
shouldn't you extend CI_Controller not Controller?
anyway I think the problem is view, $controller = $this->uri->segment(1); - this returns admin if I'm not wrong
#3

[eluser]the_unforgiven[/eluser]
Yes it's an admin page for admin only so what should I do to rectify this problem??
#4

[eluser]Aken[/eluser]
Have you already done the steps necessary to remove index.php from the URL structure?

If not, you will have to access your page at http://localhost/index.php/mcd/admin/sym

The problem is not in the controller's code, because as of right now it can't even find it (404 error).

If you are using a recent version of CodeIgniter, you should extend CI_Controller as eggzy said.
#5

[eluser]the_unforgiven[/eluser]
Yes index.php has been removed. htaccess also set up
Code:
Routes setup:
$route['sym/:any/rawDetails'] = "sym/getRawDetails";
$route['sym/:any/rawAccessories'] = "sym/getRawAccessories";   termplate
$route['sym/:any/rawQuote'] = "sym/getRawQuote";
$route['sym/:any'] = "sym/getBike";
$route['sym'] = "sym";
---------------------
htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #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>
Code:
$config['index_page'] = "";
$config['base_url']    = "http://localhost/mcd/";

in config file
#6

[eluser]eggzy[/eluser]
do you have admin controller?
try http://localhost/mcd/sym/admin
#7

[eluser]the_unforgiven[/eluser]
The admin controller is a seperate file but yes and other pages work and I have only copied what I did previous but now for some reason is doesnt work

this doesnt work either -> http://localhost/mcd/sym/admin just shows html page for frontend.
#8

[eluser]the_unforgiven[/eluser]
Sorry guys just realised I had not adding in a new class in the model therefore this wasn't working but it's working now, my mistake but thanks to all for helping.




Theme © iAndrew 2016 - Forum software by © MyBB