Every website used to be like “www.example.com”. Now I rarely encounter this “www.”. Why did it even exist and where has it gone? I also used to run into websites with legitimate domains, but “ww1.” instead of “www.”, these were probably phishing sites, but how did this actually work on top of legitimate domains?


Newer, yes. Not very new.
The URL format of protocol://hostname.domain:port/path was defined in 1994. Prior to that you would use use an ftp client, usually on the command line like:
ftp hostname.domain