htaccess rewrites, base href, and anchors

Discussion forum for MOD Writers regarding MOD Development.
Registered User
Posts: 173
Joined: Mon Jan 26, 2004 8:37 am

htaccess rewrites, base href, and anchors

Post 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:

That gets translated to 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 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?!

Return to “[3.0.x] MOD Writers Discussion”