A while back, I discovered a DNS name that would allow me to use subdomains with localhost development tasks. "lvh.me" This was a fantastic find until one day it didn't work. It turns out the folks responsible for keeping that name registered decided it was no longer needed, and thus in one poof, it was no longer helpful.
While this was only for development purposes, no big deal, but I wanted to see if I could stand up my own. Here is what I did. If you want another link, feel free to use: "127dev.link"; it honors subdomains and ports and is a simple replacement for 127.0.0.1 (localhost).
for example: localhost:3000 works great, subdomain.localhost:3000 does not
However, 127dev.link:3000 works, so does subdomain.127dev.link:3000
127dev.link will point to YOUR LOCAL machine since it resolves to 127.0.0.1.
Use 127dev.link, or make your own. I do make the assumption that you are familar with domain name registration and DNS record creation/management so I won't go into that here.
- Register your domain
- Create a raw DNS A record pointing to 127.0.0.1
- Create another A record with the subdomain of "*" pointing to 127.0.0.1
- If you want mail, create your MX records as usual
I had this version setup and configured in about 20 minutes which includes the name registration and DNS record creations in addition to the time for the servers to update.
Keep in mind that this link only resolves the address; no data is really set outside your network other than your name resolutions. This DOES require a network connection to resolve the link, but it resolves to 127.0.0.1, so it's localhost with subdomain capabilities. Also, if you make your own, then you are in 100% control of even the name resolution part.
That's it - you now have your own "localhost" replacement. Well, once your registrar updates their records.