Fix to rewrites. Caused 404 in different cases.