Fix broken GET variable

I am using a GET variable to select a specific item to display on the page. My URL would usually look like:

/?type=xxxx

I then have a login plugin (WordPress) which adds ?redirect=ok to the URL on submission. Unfortunately, this then makes the URL look like: /?type=xxxx?redirect=ok which breaks the previous variable.

Read More

I am trying to edit that URL somehow. I thought about a few methods:

  • .htaccess to find and rewrite the ?redirect=ok to blank or to &redirect=ok
  • PHP to strip that part out of the string and then redirect

None of these seemed to work.

Any help would be massively appreciated.

Related posts

Leave a Reply

1 comment

  1. Here is mod_rewrite fix for this strange problem.

    Put this code in your DOCUMENT_ROOT/.htaccess file as very first rule:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} s/+([^?]*?type=.*?)?(redirect=ok) [NC]
    RewriteRule ^ %1&%2 [R=301,L]