Redirect if get parameter is empty

#477080
  • Resolved Witzel Digital
    Rank Math free

    We are building a sign-up form for a gym. We have a page that contains a form for the sign-up. In there we have a hidden field to determine the contract that the user selected and it is pre-populated by the get parameter.

    For example:

    /deals/ -> The page for the different contracts

    From here I click on my selection and I go to the form.

    /deals/sign-up/ -> The page with the sign-up form

    After I click on contract 1 on the deals page, my structure looks like this:

    /deals/sign-up/?contract=1 -> The form knows now that we selected contract one.

    What we try to achieve now is that in case someone enters directly to /deals/sign-up/ he gets redirected to /deals/ since he has not made a selection yet and the form does not know which contract he chose.

    So what we need is a redirection that detects if there is no get parameter and then send us back to the /deals/ page.

    I hope it was understandable πŸ˜€

    Thank you very much for your help!

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    This is not something that can be done with our plugin but rather it would require some custom code to be added to your website. You could reference this page to see an example of this: https://stackoverflow.com/questions/43394705/wordpress-redirect-if-url-parameter-is-empty-for-each-post

    ​​​​​​Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Redirect if get parameter is empty’ is closed to new replies.