0

I was wondering if index.html is a relative URL or not.

I know that Website/Pages/index.html is a URL. But what if it was just the file name and file extension without the path? Would it still be called a URL?

unor
  • 92,415
  • 26
  • 211
  • 360
tainehu
  • 15
  • 3

4 Answers4

2

Both of your examples are relative paths, not urls.

Relative url examples:

<A href="suppliers.html">Suppliers</A>
<IMG src="../icons/logo.gif" alt="logo">
<IMG src="image/logo.gif" alt="logo">

A relative URL (defined in [RFC1808]) doesn't contain any protocol or machine information. Its path generally refers to a resource on the same machine as the current document. Relative URLs may contain relative path components (".." means one level up in the hierarchy defined by the path), and may contain fragment identifiers.

SRC: http://www.w3.org/TR/WD-html40-970917/htmlweb.html


URL Definition:

URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet. A URL has two main components: Protocol identifier: For the URL http://example.com , the protocol identifier is http . Resource name: For the URL http://example.com , the resource name is example.com.

SRC: https://docs.oracle.com/javase/tutorial/networking/urls/definition.html (this is a url)


Absolute path:

/home/you/index.html

Relative path:

you/index.html
index.html

Absolute and relative paths

An absolute or full path points to the same location in a file system regardless of the current working directory. To do that, it must contain the root directory.

By contrast, a relative path starts from some given working directory, avoiding the need to provide the full absolute path. A filename can be considered as a relative path based at the current working directory. If the working directory is not the file's parent directory, a file not found error will result if the file is addressed by its name.

SRC: http://en.wikipedia.org/wiki/Path_(computing)

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
0

What a path relative URL is

And, yes, index.html can be a relative url.

When referring to a file that occurs in the same directory as the referring page, a URL can be as simple as the name of the file

If you want to link to your index.html page from your about.html page, as long as they're in the same directory you could very simply do:

<a href="index.html">Index</a>

What i think you are confusing is absolute vs relative paths. As other's are describing, a URL with an absolute path needs to be defined by:

  1. protocol: (http://)
  2. domain: (bobsjingles.)
  3. extension: (edu)
  4. directory path: (/journeycovers)
  5. fragment: (/index.html)

http://bobsjingles.edu/journeycovers/index.html

All that absolute path does (essentially) is point to an IP / port on a machine, where you can send a request under a specific protocol (http), and get an expected data result (html.)

wahwahwah
  • 3,254
  • 1
  • 21
  • 40
0

In a HTTP URL like http://example.com/index.html, /index.html is the URL’s path.

HTTP URLs don’t "know" or care about file names or file extensions.

There is no conceptual difference between paths like /index.html, /index_html, /index, /index/foo/html, or /foooo. (Servers, on the other hand, might use various conventions, like appending a dot followed by a file extension, to do something if such a URL is requested.)

unor
  • 92,415
  • 26
  • 211
  • 360
-1

URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet.

Having said that, a file name with its extension is not a URL as it is not enough to determine the location of the file on the internet.

However, a file name and its extension can be referred to as a URI.

URI can be a locator (http://example.com) or a filename (example.txt) and the combination of both is the URL (and can still be called a URI).

Here is the complete RFC3986 for your reference.

Read this article to help you understand more the difference between URIs and URLs along with some examples

Community
  • 1
  • 1
Tarek
  • 687
  • 5
  • 11