How to redirect the page In the front-end, I create a form and submit the data to backend. In the controller, if got some errors, I would like to redirect to the previous page with some information.
If you're using the Pixel &amp; Tonic Contact Form plugin then there is a way to set your redirect using {{ redirectInput('contact/thanks') }} as seen here: https://github.com/craftcms/contact-form

However, I've just noticed you've tagged this question with plugin-sproutseo, but I'm not aware of that plugin interacting with contact forms in any way.

To more specifically try to answer your question, firstly to redirect and pass some information, I have used query params before so I've set my redirect link to be /thankyou?name={{ formstuff.name }} so I can access the user's name with:

{% set name = craft.app.request.getParam('name') %}


Now when it comes to redirecting back to the user's previous page, have a read of this answer below. It's a few years old, but it'd potentially still give you an option to resolve your issue: https://craftcms.stackexchange.com/a/13488/5845

EDIT: After a look at some other questions, I've noticed this one has an almost identical wording so this one should be marked as duplicate. See dupe below:

How to redirect the page with params?