Issues with duplicate pages url with slug and without

I’m trying to solve an issue on a classified ads website ,i recently did an seo site audit, which revealed that almost all my categories and sub-categories pages have duplicates ,and every time i create a new category it will create two links :

I can access the category from both link without any problems ,but for seo it’s not that nice ,and i have to do something (here i hope that you can help me ) in order to avoid this.
I think that maybe a redirect of all ‘…’ to ‘…’ should do the trick ,but i don’t know how to do it and where to put it (urlmanager,htaccess…) !

Unfortunatelly i am not too familiar with yii framework or php so any help it will be very appreciated !
If you need any other details ask me and i will provide them !