extracting the rewrite code to a separate function
Merge branch 'refs/heads/rewrite_cookie_path' into clean_version