I have a local server for development with addresses like "http://dev.local"

However when typing: "//dev.local", Chrome will search on Google instead of going to the specified address.

I need this to work for development purposes, is there a way to prevent Chrome from searching // URLs without disabling search from the address bar for all other inputs?

up vote 1 down vote accepted

Is there a way to prevent Chrome from searching // URLs without disabling search from the address bar for all other inputs?

Yes. Add a trailing slash / like you would to any other local address to bypass searching Google, etc. e.g. //dev.local/.

Note that items accessed directly (e.g. //dev.local/image.jpg) should work correctly as-is (i.e. no trailing slash should be required).

  • Yeah, I was using this before also, not a bad idea as it's working with basic url names, however is it custom to also use this on a file? //dev.local/image.jpg/ – NaturalBornCamper Mar 22 at 14:51
  • 1
    @NaturalBornCamper no, this depends how the server handles the path provided... If it's static content, then this will not typically work. In this case it will try to resolve /image.jpg/, which could be a directory, a file, or even a path handled by an active backend (e.g: PHP). – Attie Mar 22 at 15:09
  • You're right, this works actually, I just hadn't tried with a domain that was set in my hosts file yet. Seems like if Chrome can reach the domain, it's not complaining for image files! Thanks friend! – NaturalBornCamper Mar 23 at 17:04
  • You're welcome. Glad everything seems sorted out. =) – Anaksunaman Mar 23 at 17:08

URLs consist of multiple parts: (wiki)

scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]

As such, typing //dev.local doesn't fit into the pattern above, and the omnibox will interpret this as a string to pass to a search engine.

You have three options:

  • Be explicit - http://dev.local - always the best option
  • Give an empty scheme - ://dev.local - Chrome appears to default to http
  • Give the bare hostname - dev.local

In the third case (with local DNS and Chrome's cooperation) you'll see something like this:

In Chromium, we decided that consistency and speed was best, and given that the range of 'single-word inputs meant as searches' dwarfs the number of 'single-word inputs meant as URLs', we default to displaying web search results while doing a background DNS lookup to figure out if a local host exists - if it does, we display a "Did you mean http://input/" infobar as show below:

chrome did you mean cheese

  • Thanks for your comprehensive answer, I'll wait for a few days in case someone knows a hack before accepting :) – NaturalBornCamper Mar 22 at 14:49
  • "A hack" is not something you should rely on... for anything. – Attie Mar 23 at 10:13
  • 1
    For development, better than nothing ;) – NaturalBornCamper Mar 23 at 16:58

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.