Question

I just installed CodeIgniter 2.1.4. I want to call several functions in a controller. I have the following code:

Controller galeria.php:

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

class Galeria extends CI_Controller {


public function index() 
{
    $this->load->view('vgaleria');
}

public function tg() 
{
    $this->load->view('tgaleria');
}
}

?>

Views:

<!DOCTYPE html PUBLIC>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Galería de imágenes</title>

<style type="text/css">
</style>

<script src="<?php echo base_url(); ?>javascript/funciones.js"  
    language="javascript" input="type/text">
</script>
</head>
<body>

<div id="imgs">
<img src="imagenes/imagen1.jpg" id="eimg">
</div>

<input type="button" id="bant" onclick="imgav('atras')" value="Anterior"></button>
<input type="button" id="bsig" onclick="imgav('adelante')" value="Siguiente"></button>

</body>
</html>

View tgaleria.php:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Galería de imágenes</title>

<style type="text/css">
</style>

<script src="<?php echo base_url();?>javascript/funciones.js"  
    language="javascript" input="type/text">

</script>
</head>
<body>

<div id="imgs">
<img src="imagenes/imagen1.jpg" id="eimg">
</div>

<input type="button" id="bant" onclick="imginter('arrancar')" value="Arrancar">   
</button>
<input type="button" id="bsig" onclick="imgparar()" value="Parar"></button>

The default controller is galeria.php.

$route['default_controller'] = "galeria";

When I type http://example.com/codeigniter I have everything ok.

But when I type http://example.com/codeigniter/tg.php I obtain the error 404, url not found.

How can I fix it?

Thanks.

Was it helpful?

Solution

Have you used .htaccess to remove the index.php? if not then you must append it like:

http://example.com/codeigniter/index.php/galeria/tg 

else

http://example.com/codeigniter/galeria/tg

Here, galeria being your Controller and the first segment and tg your function and the second segment of the URI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top