链接不回目录? [英] Links not going back a directory?
问题描述
www.mysite.com
。在本网站中,我有一些常见问题解答,但建立网站的人员将FAQ页面保存在名为常见问题解答的网站上的目录下。 作为例子,常见问题解答页面将位于:
www.mysite的.com /页/ EN /常见问题/ FAQ-page1.html
。
请注意 pages / en /
目录。理想情况下,我希望所有网页都保存在 www.mysite.com/index.html
等下,但我无法更改。
无论如何,当我在这些常见问题页面中的任何一个上,我尝试回到主页 index.html
时, t转到页面。例如,当我在上面时:
www.mysite.com/pages/en/faqs/faq-page1.html
我试着链接回主页
www.mysite.com/pages/en/index.html
(这是保存索引页的地方),导航不起作用。相反,它会尝试去 www.mysite.com/pages/en/faqs/index.html
。
现在我假设发生这种情况是因为我处于faq目录中,但如何在链接时返回根目录?链接的代码只是< a href =index.html>主页< / a>
。我当然可以放入完整链接 www.mysite.com/pages/en/index.html
,这可以解决这个问题,但还有其他解决方法吗?对不起,如此长的帖子,我可能已经能够更好地解释这一点,但我不能:S $ / b
$ b
预先感谢。
您需要提供< a href =../ index.html> Home< a>
或者,您可以指定从您的网站的根目录中链接
< a href =/ pages / en / index.html>主页< / a>
。
在文件路径中有特殊含义, ..
表示一个目录,。
表示当前目录。 so < a href =index.html> Home< / a>
与< a href =./ index.html>主页< / a>
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.
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>
这篇关于链接不回目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!