Link to index page of website

Kendall Frey picture Kendall Frey · May 12, 2012 · Viewed 35.9k times · Source

Is there a way to link to the index page of a website without specifying the name of the index page or the full website URL?

I have this:

<a href="index.htm">Home</a>

But when I click the link, my address bar shows:

mydomain.com/index.html

I would like it to show:

mydomain.com

Can I do that without putting the full URL (mydomain.com) in the href? If so, how?

For future viewers, I also found this question helpful.

Answer

James Allardice picture James Allardice · May 12, 2012

You can just do this:

<a href="/">Home</a>

Any href preceded by a slash is relative the root directory.

It should be noted that when viewing a webpage from a local hard drive in a browser, this will cause the link not to function.