views:

109

answers:

1

I've set up a brochure ware kind of site - with links to different sections in the page.

http://www.leoniepalmer.com/

When clicking a menu item in the top right corner, everything works great!

Now I have a second page at

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

And I want the menu to then go back home to the relevant anchor, that is, clicking About will go to

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

Unfortunately (in FF 3.5.6 at least), it seems to append it to the URL and it becomes quite ugly, as well as not going to where it should!

Could it be this rule in my .htaccess, that appends a trailing slash to pages without one?

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

How could I modify it to work, or is there something else at play here?

UPDATE

I don't think the answer is helpful at all.

You can link to an Id using the #anchor fragment.

+1  A: 

OK, I'm guessing it's because you're using a <div> tag as the target of a link. Properly, named tags that are the target of links to a location in a page are also <a> tags, your syntax is similar to <a name="about">About Leonie and Stef Palmer</a>

Here's the source:

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

Just to be safe, you might want to make the link in your navbar to the full document:

<a href="http://www.leoniepalmer.com/index.php#about"&gt;About&lt;/a&gt;

Not only is this one of the use cases described above, it saves Apache some work. Including the full path lets the browser go straight to the page, whereas not including the name of the document means the browser has to ask Apache on your server what the name of the page is and then go there - 2 connections for the price of 1

Matt
I believe looking up DirectoryIndex is a small tradeoff to have pretty URLs
alex
You can use an Id as a anchor target. See on the home page - works beautifully (disable JS to see static browser behaviour)
alex