append query string to url when appropriate