I’m working on this project wherein I wanted to change the URL of an existing /controller/action/ generated by bake.
I have a ForumThreadsController and a ForumCategoriesController.
From my forum-threads index.ctp page, I have created a dropdown filter so I can sort my categories.
However, upon selecting a certain category, I will be directed to this URL: project.com/forum-categories/view/<selected_id>
I want to change this URL to project.com/forum-threads?forum_category_id=<selected_id>
I have already been working with config/routes.php and .htaccess.
Here is my routes.php:
Router::defaultRouteClass(DashedRoute::class);
Router::scope(‘/’, function (RouteBuilder $routes) {
$routes->connect(‘/’, [‘controller’ => ‘home’, ‘action’ => ‘index’]);
$routes->connect(‘/support/*’, [‘controller’ => ‘support’, ‘action’ => ‘display’]);
$routes->fallbacks(DashedRoute::class);
});Plugin::routes();
And here is my .htaccess:
RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L]
Nothing seems to work for me yet.
Thanks in advance for your help.