Links not going back a directory?

zik picture zik · Feb 1, 2011 · Viewed 148.5k times · Source

this is probably a silly question and I have the answer myself but I want to know if I am doing anything wrong. I have a website, let's call it www.mysite.com. Within this site, I have some FAQs but the person that built the site saved the FAQ pages under a directory on the site named "FAQs".

As an example an FAQ page would be located at:

www.mysite.com/pages/en/faqs/faq-page1.html.

Note the pages/en/ directory. Ideally I would like all the pages to be saved under www.mysite.com/index.html etc but I can't change this.

Anyway, when I am on any of these FAQ pages, and I try to link back to say the home page index.html the navigation won't go to the page. So for example, when I am on:

www.mysite.com/pages/en/faqs/faq-page1.html

and I try to link back to the home page

www.mysite.com/pages/en/index.html (which is where the index page is saved) the nav won't work. Instead it will try to go to www.mysite.com/pages/en/faqs/index.html.

Now I am assuming this happens because I am in the "faq" directory, but how do I go back to the root directory when linking? The code for the link is simply <a href="index.html">Home</a>. I could of course just put in the full link www.mysite.com/pages/en/index.html, which would solve this but is there another way around this? Sorry for such a long post and I may have been able to explain this better but I can't :S

Thanks in advance.

Answer

Robb picture Robb · Feb 1, 2011

You need to give a relative file path of <a href="../index.html">Home</a>

Alternately you can specify a link from the root of your site with <a href="/pages/en/index.html">Home</a>

.. and . have special meanings in file paths, .. means up one directory and . means current directory.

so <a href="index.html">Home</a> is the same as <a href="./index.html">Home</a>