• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
routes not work, only default method, CI4

#1
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
Reply

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

#3
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(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 
Reply

#5
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);
Reply

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

#7
OK: solved it, problems with apache2 :

rewite_engine is off and .htaccess files is default disabled
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.