clean url path and redirect if necessary