How do I add a subcategory to the URL slug for a channel entry? I'm trying to mimic the URL structure exactly how I have it in my old CMS. If I select an entry to have both a category and subcategory I would like to have the subcategory in the URL along with the category and the entry slug.

For Example

http://example.com/cat1/subcat1/entry


Right now I have the Entry URL Format set to be {category.first().slug}/{slug}, but that only shows the first category. How do I access that optional subcat1 subcategory in that field?

EDIT

I have tried the following but it doesn't work

{category.first.slug }/{ category.first.children.first.slug ? category.first.children.first.slug ~ '/' : '' }{slug}


I have also tried 

{category[0].slug}/{ category[1] ? category[1].slug ~ '/': ''}{slug}
If you go into your Category Group’s settings and set the following settings:


Craft 2


Top Level URL Format: {slug}
Nested URL Format: {parent.uri}/{slug}

Craft 3


Category URI Format: {parent.uri}/{slug}



then you would be able to set your section’s Entry URL Format to this:


Craft 2

{myCategoryField.last.uri}/{slug}

Craft 3

{myCategoryField.inReverse().one().uri}/{slug}