有效地使用相对URL方案 [英] Using a relative URL scheme effectively
问题描述
使用具有在这个问题的基本标签使它很难在我的网站上使用。
我在我的网站有一个导航菜单,引用我的不同部分site
例如
main /
| _index .html
| _section1 /
| _1a.html
| _1b.html
和每个页面上的导航部分看起来像
< div id =nav>
< ul>
< li>< a href =index.html>家< / a>< / li>
< li>< a href =section1 / 1a.html> 1a< / a>< / li>
< li>< a href =section1 / 1b.html> 1b< / a>< / li>
< / ul>
< / div>
这适用于 我担心的是,如果我在所有页面上使用绝对引用,那么当我将此网站上载到服务器时,将需要大量工作来替换绝对引用在每个页面上使用不同的页面。 此外, 我猜如果我被推送了,我可以使用 您可以使用 Using has all of the issues on anchor-tags that were described in this question on base tags making it hard to use on my site. I have a navigation menu in my site which references different parts of my site for example and the navigation section on each page looks like This works fine for all the pages on in the I'm concerned that if I use absolute references on all my pages, when I upload this site to a server it will be a huge amount of work to replace the absolute reference on each page with a different one. In addition I guess if I was pushed I could use You can make use of 这篇关于有效地使用相对URL方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! main $ c中的所有页面$ c>文件夹,但是当我在
section1
文件夹中查看页面时,显而易见的原因失败。我不能使用< base>
,因为我在文档中有大量的锚点(并且我使用降价,所以我不能轻松更改引用格式) / p>
main
是在 / home /
目录,我宁愿不必在每次引用某些内容时都键入一个长路径名称。
sed
来改变绝对路径的所有实例,但我想知道是否有一个更容易,明显的方式来处理这个在HTML中,我失踪了。谢谢
htaccess
t在HTML中使用< base>
main/
|_index.html
|_section1/
|_1a.html
|_1b.html
<div id="nav">
<ul>
<li><a href="index.html">home</a></li>
<li><a href="section1/1a.html">1a</a></li>
<li><a href="section1/1b.html">1b</a></li>
</ul>
</div>
main
folder but for pretty obvious reasons fails when I'm viewing a page in the section1
folder. I can't use <base>
because I have a large number of anchors in documents (and I'm using markdown so I cant change the reference format easily).main
is a few levels down in my /home/
directory and I would prefer not to have to type a long path-name each time I refer to something if possiblesed
to change all instances of the absolute path with something else but I wondered if there was an easier, obvious way of dealing with this in html that I'm missing. thankshtaccess
, if you can't use <base>
in HTML