var url = 'https://site.com/path/file.php?id=1¶m='; alert([ url.replace(/^https?:\/\/[^\/]+(\/.*)/, '$1'), url.replace(/^https?:\/\/[^\/]+/, ''),// или так ]);