Updated redirect() function

redirect() function now handles ajax redirects by returning a page
object, to work with the fact that ajax requests now return JSON arrays