Jump to content

Redirect 301 after POST form submit


Recommended Posts

Hi friends! And thanks for Processwire!

I've got a strange PW behavior which i cannot explain. Maybe i'm missing something. I have a form with method=post and action=action_page (different from page where the form resides). I'm trying to use post vars in the action_page's template. Both $_POST and $input->post() are empty. Deeper analysis shows that PW performs a http 301 redirect to action_page after the form is submitted, so all post vars are no longer available. How can i prevent PW from doing so? Did some simple tests to find the reason, i'm 95% sure that the redirect is triggered by PW. Thanks in advance for any advice!

Link to comment
Share on other sites

I just had this problem as well, using path hook like this:

wire()->addHook('/my/path', function($event) { /*…*/ });

In conjunction with a form like this:

<form method="POST" action="/my/path/">

ProcessWire redirects the version with the trailing slash to the path matching the hook. I presume the same thing happens with normal pages and url segments as well, depending on the template settings.

So if your redirect goes from /action_page to /action_page/ or vice versa, just request the exact url directly.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...