How long are my URLs?

We are trying to reduce the allowed URL length in one of our applications for security reasons. The first question that you need to answer when doing an optimisation like this is “how many characters do I need to keep my application running?” You can look through your apache log files to find out. Here is a command-line script to help you find out how long your URLs are:

cat access.log* | cut -d" " -f7 | awk '{ print length($0),$0 }' | sort -nu

One thing I noticed is that apache logs URL-encoded strings so the line lengths are too high if you have multibyte or special characters in your URLs. I was able to read the results  and do the maths manually this time but I will probably need to sort that out for the next round.

Advertisements