15

For web development on localhost I'm using domains with .loc extension at the end of a domain name.

For example: if I work on a site roses.com, the local development domain would be roses.loc (defined in hosts file and IIS as a host-header in binding)

My preferred browser (the main browser I use for development is Chrome) but unfortunately it does not recognize a domain name with .loc extension as http://rose.loc - it throws me onto a google search page each time I would type in rose.loc (without http://) in the beginning..

Have you experienced this in a similar way ? Is there some solution to that ?

Because during intensive development testing with clearing browser cache and restarting the browser for various reasons, it's getting pretty annoying to be thrown at a google search page instead of the development page where I expect to notice some changes, each time I forget to type in http:// before the url (and Chrome is the one who hides it by default, anyway..)

jww
  • 97,681
  • 90
  • 411
  • 885
Denis
  • 4,718
  • 5
  • 18
  • 20
  • 1
    You can use [`.test` domain](https://en.wikipedia.org/wiki/.test) and `example.com`. They are reserved for the purpose. `*.loc`, `*.dev` and `*.tld` (and friends) are not reserved and cannot be hijacked by the developer. – jww Sep 20 '18 at 03:13

4 Answers4

16

Google Chrome is pretty "smart" with this. It uses a list of known-good TLDs and assumes everything else is just a search term that happens to end in a dot followed with some characters.

99% of the time that's perfectly fine. It's "only" us developers and a few people with strange network setups that have to suffer for the good of the majority ;-)

You can try using .local as your TLD, as that's a defined domain for referencing local domain names (at least it's used in some mDNS systems).

The issue has been entered as #30636 in the Chromium bug tracker. One workaround that often (but not always) seems to work is to append / to your hostname. So try roses.loc/.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • "Stange" network setups including any which search local domains first (pretty standard). If I'm on host.mynetwork.com I expect to be able to access host2.mynetwork.com by referring to "host2". This makes Chrome significantly more painful than FF for no gain whatsoever (FF's URL bar is pretty smart too and doesn't suffer from this problem) – Draemon Nov 07 '12 at 16:34
  • 1
    We noticed that if we're trying, for example to open "http://mysite.loc", then it won't work, but take us to google search results page... but: if you type this as "http://mysite.loc/" (with the dash at the end), then it works and takes us to http://mysite.loc - just had to mention this. – Denis Jan 21 '13 at 20:11
  • `*.loc`, `*.dev` and `*.tld` (and friends) are not reserved and cannot be hijacked by the developer. – jww Sep 20 '18 at 03:14
5

I've created a search engine with a keyword of 'l' (my local TLD is .l). The URL for the search engine is http://%s.l. Then, I simply type "l mysite" in the address bar and it takes me to mysite.l.

jessepinho
  • 5,580
  • 1
  • 19
  • 19
0

Here is a workaround I came up with for this bug: http://code.google.com/p/chromium/issues/detail?id=30636#c38

Hayden Schiff
  • 3,280
  • 19
  • 41
0

I have Chromium installed on Linux Mint, and have a few localhost websites here. (I use Firefox for all of my work, so I have just discovered something here with Chromium.) My local sites are called morse and a.z. I had to enter http://morse/ and a.z/ respectively to get these sites to load the first time. They produced quick links on the new tab's otherwise blank page.

After closing Chromium, I reopened it and I could enter just morse/ and a.z to visit these sites. Since I've never seriously used this browser, I have not tailored any settings in it. (I did not use the quick link icons, but instead typed in the address bar.)

My findings confirm the localhost example.TLD/ entry does work when entered for the first time.

About Chromium: I am using Version 106.0.5249.119 (Official Build) for Linux Mint (64-bit).

AZM
  • 1