I ended up getting it to work with just the following line. No location or anything. rewrite ^.*-t([0-9]+).html$ /showthread.php?t=$1 last; thanks everyone for your help!