mahipal negi
mahipal negi

Reputation: 317

cake 3:- how to use htaccess RewriteRule in cakephp 3?

I am working on cake 3.

i have a cake 3 URL:- www.test.com/users/account/john

and want this URL like www.test.com/john

i don't have any idea how to do this, please let me know how to do this.

Upvotes: 0

Views: 296

Answers (1)

Salines
Salines

Reputation: 5767

// config/routes.php

Router::scope('/', function ($routes) {
    //...
    // add at end 
    $routes->connect('/*', ['controller' => 'Users', 'action' => 'account']);

}


//

//UsersController.php

public function account($slug = null){
 // your code here
}

// in view
echo $this->Html->link('John',['controller' => 'Users', 'action' => 'account','john']);

Upvotes: 0

Related Questions