У меня небольшая проблема
Это мой контроллер CapturistaCtrl.php:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class CapturistaCtrl extends CI_Controller {
public function index(){
echo "index";
}
public function alta(){
echo "alta";
}
}
это мой routes.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['default_controller'] = 'Welcome';
$route['capturista'] = 'CapturistaCtrl';
на config.php:
$config['base_url'] = 'http://localhost/captura';
$config['index_page'] = '';
и .htaccess
RewriteEngine On
RewriteBase /captura/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Если я помещаю этот URL: http: // localhost / captura / capturista, я получаю текст «index», это означает, что метод index () на моем контроллере работает, но если я помещаю http: // локальный / captura / capturista / alta, я получаю страницу 404.






Использование группы захвата регулярных выражений (...).
Пытаться:
$route['capturista(.*)'] = 'CapturistaCtrl$1';
Альтернатива, используя: любой подстановочный знак.
$route['capturista/(:any)'] = 'CapturistaCtrl/$1';
$route['capturista'] = 'CapturistaCtrl/index';
Обновил свой ответ. Используя всего одну строчку.
****controller code****
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class CapturistaCtrl extends CI_controller
{
public function index(){
echo "index";
}
public function alta(){
echo "alta";
}
}
**routes.php**
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['capturista'] = 'CapturistaCtrl';
$route['capturista/(:any)'] = 'CapturistaCtrl/$1';
// (or any one )$route['capturista/alta'] = 'CapturistaCtrl/alta';
**.htaccess**
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
**config.php**
$config['index_page'] = 'index.php';
remove (index.php)
$config['index_page'] = '';
$config['uri_protocol'] = 'index.php';
remove (index.php)
$config['index_page'] = '';
Просто прочтите документацию CodeIgniter и следуйте инструкциям по ее использованию.