curl error [globbing] bad range specification

When testing some website redirects with curl from the command line, I got the error message "curl: (3) [globbing] bad range specification in column 120"

Escape [ and ] or use -g or –globoff

An example URL that will cause the error is this:

curl "http://www.example.com/?test[]=123"

Either escape the square brackets like this:

curl "http://www.example.com/?test[]=123"

or use –globoff like this:

curl --globoff "http://www.example.com/?test[]=123"

or the shorter -g like this:

curl --g "http://www.example.com/?test[]=123"