Redirecting before the header sent caused an infinite loop. Trying template action now.