I have not figured out when I should use one or the other. What are the rules''
General rule (it doesn't cover all uses):
"Para" is used to indicate the person, place or approximate time at which people or things end up. "Por" is used to indicate where or why you are going through a place or doing something, i.e. to give reasons, indicate where you are going through. "Por" has more uses than "para", but I won't describe them all here.
Please see this in our reference section.