fix a redirect bug when first visit empty database