How to codeigniter in route to declare a class

For example, I do like this

 class admin extends CI_Controller { public function test() { echo"helloworld"; } } 

How can I see the page at http://site.ru/admin/test

    2 answers 2

    To do this, you just need to properly configure .htaccess

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

    Then in the config.php file you need to configure

     $config['url_suffix'] = ''; 
    • I’m not exactly talking about this)) I’m talking about routes and my classes. - Dima
    • For example, declared a class, how can I see it in the url? - Dima
    • Have you tried to do site.ru/index.php/admin/test ? If yes, then my answer will solve the problem. - Saidolim
    • I open localhost / index.php / admin / index , there is nothing. - Dima
    • Class admin extends class CI_Controller {public function index () {echo "asd"}} - Dima

    aplications / controllers / admin.php - if so is the controller, then

     $route['somme_link'] = 'admin/test'; 

    if the controller is located in a subdirectory, for example aplications / controllers / admin / admin.php, respectively

     $route['somme_link'] = 'admin/admin/test'; 

    somme_link is respectively the part of the link (after the domain) that you go to http://site.com/somme_link