tar - Remove leading directory components on extraction

How can you extract only the target dir and not the complete dir tree?

compress

tar cf /var/www_bak/site.tar /var/www/site

extract

tar xf /var/www/site.tar -C /tmp

This will produce:

/tmp/var/www/site

How is it possible to avoid the whole dir tree to be created when the file is extracted?

What I want it to extract to:

/tmp/site

Why not use -C option when creating:

$ tar cf /var/www/site.tar -C /var/www_bak/ site

You want to use the --strip-components=NUMBER option of tar:

 --strip-components=NUMBER
       strip NUMBER leading components from file names on extraction

Your command would be:

tar xfz /var/www/site.gz --strip-components=2 -C /tmp