2009-12-18 108 views
0

我已经设置了一个小册子类型的网站,并链接到页面中的不同部分。内部锚点和链接存在问题

http://www.leoniepalmer.com/

点击右上角的菜单项时,一切都很正常!

现在我有第二个页面在

http://www.leoniepalmer.com/our-gourmet-tours/

而且我希望菜单,然后回家给有关的锚,也就是点击关于将前往

http://www.leoniepalmer.com/#about

不幸的是(至少在FF 3.5.6中),它似乎将它附加到URL,它变得相当丑陋,以及不去它应该的地方!

难道这是我的.htaccess中的这条规则,追加一个没有一个页面的斜线?

# Add trailing slash if missing 
rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L] 

我怎么可以修改它的工作,或者是有别的东西在这里发挥作用?

UPDATE

我不认为答案是有帮助的。

您可以使用#anchor片段链接到ID。

回答

1

好的,我猜这是因为您使用<div>标记作为链接的目标。 正确,命名的标记是在一个网页链接到一个位置的目标也<a>标签,你的语法类似于 <a name="about">About Leonie and Stef Palmer</a>

这里的源:

source

This creates an anchor around the text "This is the location of anchor one.". Usually, the contents of A are not rendered in any special way when A defines an anchor only. 

Having defined the anchor, we may link to it from the same or another document. URIs that designate anchors contain a "#" character followed by the anchor name (the fragment identifier). Here are some examples of such URIs: 

An absolute URI: http://www.mycompany.com/one.html#anchor-one 
A relative URI: ./one.html#anchor-one or one.html#anchor-one 
When the link is defined in the same document: #anchor-one 

刚为了安全起见,您可能需要将导航栏中的链接指向完整文档:

<a href="http://www.leoniepalmer.com/index.php#about">About</a> 

这不仅仅是上面描述的这个用例之一,它为Apache节省了一些工作量。包括完整路径让浏览器直接进入页面,而不包含文档名称意味着浏览器必须向服务器请求Apache网页的名称,然后去那里 - 2个连接,价格为1

+0

我相信查找DirectoryIndex是一个小取舍,有漂亮的网址 – alex 2009-12-18 04:12:16

+0

您可以使用Id作为锚点目标。在主页上查看 - 精美地运行(禁用JS以查看静态浏览器行为) – alex 2009-12-18 04:26:10