I need to have different advertisements on my website. If

I need to have different advertisements on my website. If a user visit home I need to have an ad
and if he click a category portfolio or category post or anything else, I need different image (add) in sidebar.
Question : is it possible to have a different sidebar if user is on this page, this post and or category ?
If not how can I do to do this ?
Thank you