Apply middleware based on url prefix