Getting Post ID with Topic ID - API Help Needed

A tangential question.

I am using subfolders.

I can type https://mysite,com/subfolder/t/xx and get to the topic fine.

If I type https://mysite.com/subfolder/p/yyyy it translates to https://mysite,com/t/title/xx/yyyy but does not include the subfolder so it doesn’t display.

Thoughts?