I expect the answer is going to be something so simple I\'ll want to cry, but I can\'t seem to figure it out. I\'m new to mod_rewrite.
I wanted to change my links f
Whatever you do, clicking a <a href="about/">about</a>
will append about/
onto the end of the URL. That's how relative links work.
Your choices are, in order of sensibleness:
Just remove that trailing slash. That's the cause of your problem:
<a href="about">about</a>
A relative link will replace the last section of the path (after the last /
) with your new value.
Add a preceding ../
. This is a bit hacky, but it lets you keep that valuable trailing slash
<a href="../about/">about</a>
Do a 301 redirect from /about/about
to /about
. This will cause the address bar to change from /about
to /about/about
and back again.
Maybe a bit too late to answer, but adding this one line in the <head>
section would do the trick:
<base href="/"> or <base href="your-domain-name">
You are defining all of your links in HTML relative to the current path.
You will need to change your links such that:
<a href="about/">about</a> | <a href="contact/">contact</a><br><br>
becomes (note the leading / on the urls):
<a href="/about/">about</a> | <a href="/contact/">contact</a><br><br>
When you are on a page site.com/about/us
a link like <a href="home/"
gets resolved by the browser to be site.com/about/us/home
.
The solution is to change all of your links, images, stylesheets, and javascripts to use absolute paths in your URLs, not relative ones like you have now.
EDIT: Just noticed your edit. You really should use absolute paths, not relative ones. If you want to keep the relative URLs then you will have to use something like <base href="/" />
on all of your pages.