Use the URL class to handle redirect calculations.