Change Admin access URL

Asked

Viewed 136 times

1

Guys, here’s the deal: I create several sites and systems, and most of them have an administrative area. I do until then in the basics of being "urldosite.com.br/admin".

Now, for safety’s sake as well, I want to start switching these accesses. Example, instead of being "admin" was "admin0978", but then in each system the numbers will be different.

How do I do this in Cakephp 3? How do I change Admin Access Urls in Cakephp 3? Only getting them so far by changing them all namespace of the admin controllers.

  • You do not need to modify the names of the controllers and namespaces.. Just configure routes: http://book.cakephp.org/3.0/en/development/routing.html

  • Daniel, can you give me a light how to do? Thank you!

1 answer

1

In your Project/config/Routes.php file

...
Router::scope('/', function ($routes) {
    ...
    $routes->connect('/admin0978', ['plugin' => null, 'controller' => 'admin', 'action' => 'index']);
    ...
});
...
  • I use it in Routes.php like this: 
Router::prefix('admin', function (RouteBuilder $routes) {
 $routes->connect('/', ['controller' => 'usuarios', 'action' => 'login']);
 $routes->connect('/logout', ['controller' => 'usuarios', 'action' => 'logout']);
}
 .

  • Change the prefix then friend. Change to Router::prefix('admin0987' ..... It works yes, the cake has several ways to do this.

  • But if I change it the way you said, the cake starts asking me to create the Admin0987 folder inside the Controller folder. Error: Create the class UsuariosController below in file: src\Controller\Admin0987\UsuariosController.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.