Welcome Guest, Not a member yet? Register   Sign In
I can access Controller but not method in it...
#1

[eluser]Ceros[/eluser]
Hi CI developpers,

Ok, first I had probs with calling controller
ex: http://localhost/MyProject/product/ won't work
but putting the index.php in the URL work.

Ive created a .htaccess file and now it's working. When I type my controler name, it call the index method.

Now the problems is that I can't call other method.
ex: http://localhost/MyProject/product/fobar
even if i put product/index it's not working.

I always get that "404 Page Not Found. The page you requested was not found." This is the CI 404 Page, not the one from Apache.

I'm using Apache and PHP5.

I tried different .htaccess file, AUTO, QUERY_STRING and everything else.

Thanks for your help!

Sebastien Dicaire
#2

[eluser]GSV Sleeper Service[/eluser]
post your .htaccess, there could be a problem with that.
#3

[eluser]Ceros[/eluser]
RewriteEngine On
RewriteBase /MyProject
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

It's the one from the Wiki
#4

[eluser]flaky[/eluser]
put the code of product.php here
#5

[eluser]cahva[/eluser]
Try loosing the question mark in the "index.php?"
Quote:RewriteRule ^(.*)$ index.php/$1 [L]
#6

[eluser]Ceros[/eluser]
Ok i'll try this as soon as I get home from work.
#7

[eluser]Ceros[/eluser]
[quote author="cahva" date="1264625851"]Try loosing the question mark in the "index.php?"
Quote:RewriteRule ^(.*)$ index.php/$1 [L]
[/quote]

That didn't work.

Here's my product controler:
Code:
class Produits_controller extends Controller {

    function __construct()
        {
                parent::Controller();
        }
    
    function index()
    {
        $data['test'] = "test des passage de donnĂ©es entres Controleur et Vues";
        $this->load->view('produits',$data);
    }
    
    function insert()
    {
        
        $this->load->view('produits');
    }
}

My routing:
Code:
$route['produits'] = "produits_controller";

http://localhost/LamexMVC/ -> Works
http://localhost/LamexMVC/publique/index -> works (which is my default controller)
http://localhost/LamexMVC/produits -> Works, call index
http://localhost/LamexMVC/produits/index -> Not working
http://localhost/LamexMVC/produits/insert -> Not working

My htaccess: (Tried with and w/out the ?)
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]


I tried to call a method in my default controller (Publique)
http://localhost/LamexMVC/publique/test

and it did work.

I'm confused right now. It's working in my default controller but not in the other one?

Thanks for your help
#8

[eluser]Ceros[/eluser]
Ok apparently, I can't put _controller in the file name and in the class name...

If I rename my controller: produits.php and Public class Produits, everything is working




Theme © iAndrew 2016 - Forum software by © MyBB