Cakephp 3 SEO URLS

I would like to know how we will be able to write the routing condition is I have a category named “ABC” and subcategory “XYZ”. My url needs to be like

etc…

Kindly advice me

Have you read the chapter on routing? What things have you tried?

1 Like

Then make your route as needed:

$routes->connect('/ABC/XYZ', ['controller' => 'Whatever', 'action' => 'yourneataction']);

With routing, and sorry, I don’t understand the question.

Yes, I have written a Routeclass for category and there I have written match and parse functions. Also added the route class in routes.php

but the function match and parse are not overriding in the routeclass

ABC and XYZ is dynamic, I was just trying to give an example. I need to set routing for urls like this

example.com/categoryname
example.com/categoryname/subcategoryname

Don’t overcomplicate it.
You just want…

/category/subcategory, it is pretty straight forward as @jimgwhit suggested, you need to call connect from within your routes.php file.

What have you tried so far?

1 Like

P.S. When people say “what have you tried”, they don’t want a general description. They want to see the code that you wrote. In this case, the exact route definitions that you’ve used.

Am looking for same type of routing in which categories and sub categories will be added in the link like parentcategory1/subcategory1 , the id of the subcategory1 is 3.

If the link “parentcategory1/subcategory1” is accessed in the routing needs to be for Categories/view/3

The category name pretty url will be loaded from database, while routing the id needs to be found and needed to redirecting with numeric id like something like SlugRoute

Any suggestions please. Am using version 4.2