Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an odd problem. Links to named anchors on a site I'm working on are only working correctly if the pound/hash sign is placed after a trailing slash (e.g. example.com/about/#who), rather than directly after a page name (e.g. example.com/about#who).

What could be causing this? I should note that this is on a site running WordPress, with the WPML translation plugin. I'm not sure if that's causing the problem, though (otherwise I'd ask on the WordPress Answers SE site).

Any suggestions as to what could be causing this strange behavior?

share|improve this question
Jacob Hume's answer is technically correct and comments on his answer should answer your question entirely... is there something more you are looking for before rewarding the bounty? – danlefree Feb 8 '11 at 0:42
up vote 3 down vote accepted

After some research, it looks like leaving out the trailing slash causes your browser to send out another HTTP request for the file "example.com/about#", instead of an internal link like you'd expect.

Now, I tried this kind of request on an IIS web server and an Apache web server, and both sent me back a 301 redirect to the correct URL, so I think they have some built-in functionality to handle this understandable mistake.

However, I would guess that WordPress/WPML uses Apache's mod_rewrite or something similar to make search engine friendly URLs, so that instead of example.com/about.php?user=tnorthcutt, you get example.com/about/tnorthcutt. This will probably bypass the server's normal corrective behavior. So instead of Apache redirecting you to the appropriate URL, it tries to translate it from a search engine friendly version, and everything goes south from there.

So I guess the moral of the story is to just add in the slash, and avoid the extra HTTP request altogether if possible.

Note: This is kind of wild speculation, and I'm making a lot of assumptions about your setup. Grain of salt required.

share|improve this answer
If /about isn't a directory, then there really shouldn't be a need to append a trailing slash to the URL. The server should only respond with a redirect if it can't find a file named about but does find a subdirectory named about. – Lèse majesté Feb 4 '11 at 20:37
@Lèse majesté - You'll be issued a 301 for static page URI's which are not terminated by a "/" and you would need to write a plugin to override this behavior (which, unlike post URI structure, does not allow for configuration) ... seems the WordPress devs felt strongly about that trailing slash. – danlefree Feb 5 '11 at 5:53
Weird... It sort of defeats the purpose of the trailing slash to differentiate directories from files, but good to know this info. – Lèse majesté Feb 6 '11 at 21:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.