Rear line is the one you want to disconnect and drain to a container.
Drop pan and filter to drain what you can. Replace filter, take a ball peen hammer to the bolt holes on the pan to make sure they are flat or even outdented (is that a real word :-laf

. The pan gasket should be re-usable, inspect for any damage and replace if neccessary.
Add 5 quarts fluid to transmission, start engine and idle in neutral. Watch flow out of return line and when it starts to slow, shut off engine. Do this 3 times, reinstall cooler line and fill trans to full. Usually takes around 20 quarts to exchange fluid.