var link = 'ads/category/?category_id=1&location_id=1'; link = link.replace('?category_id=',''); link = link.replace('&location_id=','/'); console.log(link);