Page 1 of 1

htaccess rewrites, base href, and anchors

Posted: Wed Jun 22, 2011 8:15 am
by Pseudonym
Hi guys, this is a general question, but I'm hoping phpBB and its resident gurus can provide me with a solution.

I've built an add-on to phpBB - a Directory service where people can list their contact details. People can access their Directory listing at an address like so:
http://www.website.com/Directory/123/YourNameHere

That gets translated to http://www.website.com/directory.php?directory_id=123 using the following code in my .htaccess file:

Code: Select all

# If directory does NOT exist...
RewriteCond %{REQUEST_FILENAME} !-d

# ...then have we asked for a Directory page?
RewriteRule ^Directory/([0-9]+)/([A-Za-z0-9\-\.]+)$ /directory.php?branch_id=$1 [L]
The problem here is that the browser seems to think http://www.website.com/Directory/123/YourNameHere is a legitimate address, and so it tries to load the CSS files from this location.

To fix that, I added the following line to overall_header.html
<base href="{SITEADDRESS}" />

That worked perfectly, and I thought I was very clever. But now I find that using the Base Href tag breaks all of phpBB's anchors. So #top and #unread don't work any more. I could go through all the template files and set the anchor links to a static URL, but that feels time-consuming and messy.

Is there a better solution? Is there some clever function in phpBB that will take care of all this?!