Restore redirect functionality removed by change 452ff19d
Use filter_var instead of parse_url to validate URLs, since the latter returns true even for invalid URLs, in particular the empty string