0

Hey guys, My WordPress permalink structure is set to `/%postname%/.

When I create a page with a name "FAQs" the permalink generated is "mydomain.com/faqs".

When I link to this page in my code (hardcoded) like this...

<a href="<?php bloginfo('home'); ?>/faqs#b" title="FAQ's">FAQs</a> (pay attention to the #b hash at the end)

...wordpress somehow automatically notices that there is a page /faqs and replaces /faqs#b just with /faqs (without the hash).

Is there a chance I can write a kind of exception to my .htaccess file so WordPress doesn't do that?

Any idea how I could make that work?

2 Answers 2

2

If your permalink structure is /%postname%/ with a trailing slash, you need to pass the hash like this: /faqs/#b with the trailing slash.

2

The URL hash (everything after the #) does not get sent to the server, so Apache or WordPress can't detect it.

WordPress redirects all URLs to the canonical version of the URL, to make sure everyone uses the same URL when linking to a post (which can help increase your ranking in search engines). This causes a redirect from /faqs to /faqs/. Browsers should append the #hash part to the redirected URL, but it seems IE does not do this.

You can prevent a redirect by using the canonical URL in the URL, like Milo suggested. So link to /faqs/#b and it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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