sneakyimp
11-23-2009, 11:55 PM
I have been working on some mod_rewrite stuff which rewrites my ugly urls into nice SEO-friendly ones. Because the directory structure of the rewritten urls is different than the dir structure on my server, my images (and CSS and Javascript) were broken.
I fixed the image/css/javascript breaking problem by using a <base> tag:
<base href="http://mydomain.com/dir1/didr2/dir3/" />
The problem is that now my anchors are broken. A link like this:
<a href="#anchor">link to anchor</a>
Is now broken. Instead of linking to an anchor within the current file, (let's call it foo.php) it tries to link to http://mydomain.com/dir1/didr2/dir3/#anchor which would refer to index.html or index.php if any such file existed. If I put in the full path to http://mydomain.com/dir1/didr2/dir3/foo.php then clicking one of these links re-loads the current page rather than just jumping to the anchor.
Is there any way to fix this problem?
I fixed the image/css/javascript breaking problem by using a <base> tag:
<base href="http://mydomain.com/dir1/didr2/dir3/" />
The problem is that now my anchors are broken. A link like this:
<a href="#anchor">link to anchor</a>
Is now broken. Instead of linking to an anchor within the current file, (let's call it foo.php) it tries to link to http://mydomain.com/dir1/didr2/dir3/#anchor which would refer to index.html or index.php if any such file existed. If I put in the full path to http://mydomain.com/dir1/didr2/dir3/foo.php then clicking one of these links re-loads the current page rather than just jumping to the anchor.
Is there any way to fix this problem?