[FIX] Properly redirect in case of invalid url slugs

Use werkzeug's api instead of doing hackish url replacement