CodeIgniter Forums
routes not work, only default method, CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: routes not work, only default method, CI4 (/showthread.php?tid=74946)



routes not work, only default method, CI4 - ctogeral - 11-27-2019

Hi for all, i need help with this..


PHP Code:
[color=#9cdcfe]$routes[/color][color=#d4d4d4]->[/color][color=#dcdcaa]setDefaultNamespace[/color][color=#d4d4d4]([/color][color=#ce9178]'App\Controllers'[/color][color=#d4d4d4]);[/color]
[color=#6a9955]// $routes->setDefaultController('Home');[/color]
[color=#6a9955]// $routes->setDefaultMethod('index');[/color]
[color=#9cdcfe]$routes[/color][color=#d4d4d4]->[/color][color=#dcdcaa]setTranslateURIDashes[/color][color=#d4d4d4]([/color][color=#569cd6]false[/color][color=#d4d4d4]);[/color]
[color=#9cdcfe]$routes[/color][color=#d4d4d4]->[/color][color=#dcdcaa]set404Override[/color][color=#d4d4d4]();[/color]
[color=#9cdcfe]$routes[/color][color=#d4d4d4]->[/color][color=#dcdcaa]setAutoRoute[/color][color=#d4d4d4]([/color][color=#569cd6]false[/color][color=#d4d4d4]);[/color]

[color=#6a9955]/**[/color]
[color=#6a9955] * --------------------------------------------------------------------[/color]
[color=#6a9955] * Route Definitions[/color]
[color=#6a9955] * --------------------------------------------------------------------[/color]
[color=#6a9955] */[/color]

[color=#6a9955]// We get a performance increase by specifying the default[/color]
[color=#6a9955]// route since we don't have to scan directories.[/color]
[color=#9cdcfe]$routes[/color][color=#d4d4d4]->[/color][color=#dcdcaa]get[/color][color=#d4d4d4]([/color][color=#ce9178]'/'[/color][color=#d4d4d4], [/color][color=#ce9178]'Home::index'[/color][color=#d4d4d4]);[/color]
[color=#9cdcfe]$routes[/color][color=#d4d4d4]->[/color][color=#dcdcaa]get[/color][color=#d4d4d4]([/color][color=#ce9178]'/main'[/color][color=#d4d4d4], [/color][color=#ce9178]'Home::main'[/color][color=#d4d4d4]);[/color] 

but not acces to main method



**SEO LINK REDACTED**

i know CI2 with php 5.6, now i use php 7.2, CI4.0.0 rc3, ubuntu apache in azure


RE: routes not work, only default method, CI4 - ciadmin - 11-27-2019

Yopu got carried away with formatting, by the look of it, rendering your post effectively inreadable. Needs fixing.


RE: routes not work, only default method, CI4 - InsiteFX - 11-28-2019

This is what it should look like

PHP Code:
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/''Home::index'); 

You are not telling us what your problem is so that we can understand it.


RE: routes not work, only default method, CI4 - gilber_fand - 11-28-2019

(11-28-2019, 04:59 AM)InsiteFX Wrote: This is what it should look like

PHP Code:
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/''Home::index'); 

You are not telling us what your problem is so that we can understand it.


when i tried open  domain.com/public/main

it trigger 404 not found, buth method Home::main exist

$routes->get('/main', 'Home::index');

i tried multiple options, like remap and not appears take main from url... 

public function _remap($method)
{
        if ($method === 'some_method') {
               error_log("method arrive".$method);
                $this->$method();
        } else {
                $this->default_method();
        }
}


error_log("method arrive".$method); only print " index" not print main when i tried 



RE: routes not work, only default method, CI4 - gilber_fand - 11-28-2019

i also tried $routes.add();

and this same

$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);


RE: routes not work, only default method, CI4 - gilber_fand - 11-28-2019

and i deployed in azure VM (ubuntu 18) i am new with azure, maybe CI has some problem with azure...?


RE: routes not work, only default method, CI4 - ctogeral - 12-01-2019

OK: solved it, problems with apache2 :

rewite_engine is off and .htaccess files is default disabled