The answer depends on whether you want to recover the original text from the URL string.
If you want to recover, first compress the text using a lossless method such as the zlib library or smaz for small text that was suggested. Then convert the compressed binary output to a URL safe format. Base64 is one such method. The final string may be shorter or longer depending on how compressible your text is.
If you don't want to recover the original text back, then simply hash your text with sha1sum and use its output in your URL string. The hash will be unique for two different input strings. Here is an example
~$ cat junk
Put all speaking her delicate recurred possible. Set indulgence inquietude discretion insensible bed why announcing. Middleton fat two satisfied additions. So continued he or commanded household smallness delivered. Door poor on do walk in half. Roof his head the what.
~$ sha1sum junk
e2acae1ae295de73541cd321da268a8d2d48ca7b junk
~$ gzip junk
~$ base64 junk.gz
H4sICFtXTF8AA2p1bmsAHU9LbgMxCN33FO8Ec4puK1XtCYhhYhQPTA3uqLcvyQbB0/vxuRI0BuIU
eqjd0WWCZWijFExpa05hnB6htyEbviWhxmvcxZrU+rNUcrGANdqUVLdCQ+wlwK3UV/8DmfmyVhEb
PpR5SBZxp0RejqDU2LW4xKxPj6goR3NLtVV4F/is+zjI+Hn7Cuk+GHHUAyYRr96/Un03vHuxz+eo
FHZcNB5VC53GvuHLfUfXKFdiZHlfnXJ7+wdZzrQRDgEAAA==
Then, use base64 -d recover the original text from the URL