Flask redirecting multiple routes
问题 I'm trying to implement a redirecting pattern, similar to what StackOverflow does: @route('/<int:id>/<username>/') @route('/<int:id>/') def profile(id, username=None): user = User.query.get_or_404(id) if user.clean_username != username: return redirect(url_for('profile', id=id, username=user.clean_username)) return render_template('user/profile.html', user=user) Here's a simple table of what should happen: URL Redirects/points to ==================================================== /user/123