added more config checks
added ensure_canonical_url( request )