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 "[]=123"

Either escape the square brackets like this:

curl "[]=123"

or use –globoff like this:

curl --globoff "[]=123"

or the shorter -g like this:

curl --g "[]=123"