optimize link generation, use rewrite when enabled