0

Complete syntax: file://host/path

If the host is localhost: it can be omitted and then resulting syntax is file:///path.

Is it actually possible to use hostnames other than localhost ? and In what situation has people ever used hosts other than localhost ?

4

2 Answers 2

-1

"file:// / path" means that you are in a local network and the last / means the root of your file system, so if you are always in a local network, yes you can omit the computer name(or hostname) but when you want to use a file that exists on another computer on the network, you need to define the hostname.

if you are always in a local network and inside your own computer, not others on the network, file:/// is better because you aren't rely on hostname(in case of if it get changed).

but if you maybe need to point a file in another computer on the network, then you need the hostname.

Is it actually possible to use hostnames other than localhost ?

localhost is a hostname itself! so when you can use localhost it means you can use other hostnames as well. if you open the hosts file(in Linux or in Windows), you can find the localhost there, that is assigned to 127.0.0.1

as a side note, if you are making a website(using a webserver), HTTP protocol maybe is a better choice for everywhere, (even relative paths is still HTTP not FILE).

Sign up to request clarification or add additional context in comments.

Comments

-1

I would discourage such activities but anyway..

On Windows you can edit the hosts file ( C:\Windows\System32\drivers\etc ) to point to specific IP or to the loopback IP(127.0.0.1 as far as I remember the last number can be changed to anything and localhost is alias to be 127.0.0.1). So you can make http://example.com point to the localhost (valid only for the modified PC).

If the current page is local (or treated as local) then it should be possible to add link file://exxample.com/C:/Users/gergo/Desktop/tmp.html in the page and it to open the other local file. (even if exxample.com points to another PC's IP)

If you want a normal web page (internet page) to open local file then probably starting the browser with allow local might work. Check link (have not tested it)Accessing local data files using Html and Chrome

Other OS and browser should be similar.

p.s. you can make hosts file redirect example.com to any IP you want. Local PC and local network are treated almost the same.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.