[ticket/12358] Correctly check and change the redirect url for ajax requests

http://tracker.phpbb.com/browse/PHPBB3-12358