Info
- 2 posts
- 2 voices
- Started 1 year ago by michaeltyson
- Latest reply from mr_pelle
- This topic is not resolved
Obligatory trailing slashes on 'name based' permalinks: Add redirect
-
- Posted 1 year ago #
Hello,
Currently, the name-based forum permalinks must have a trailing '/' - this is fair enough, but it gets seriously bad when one is typing in forum URLs and forgets the trailing '/', only to be slapped down with an unhelpful 404 error. Ouch.
I modified the .htaccess, moving the section commented 'forums' down under the 'topics' section (so the catch-some rewrite rule I added doesn't wipe that out), then added a rule that redirects URLs that address a path within the forum root, sans a trailing slash and not corresponding to an actual file, to the same path with a trailing '/'.
Like so:
# forums
RewriteRule ^([^/]+)/page/([0-9]+)/?$ forum.php?id=$1&page=$2 [L,QSA]
RewriteRule ^([^/]+)/$ forum.php?id=$1 [L,QSA] # tailed '/' is mandatory for forum URIs! Props: Mohta
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ $1/ [L,R=301] # redirect to forum URL if trailing / skipped
I'm not 100% sure why this isn't already in place - I may have missed some of the rationale. But it seems to work for me.
-
- Posted 1 year ago #
Hi! Thanks for the tip, but I have to tell you that this suggestion has been already considered and it has some backdraws.. the recent bbPM plugin bug fix, for example.
Anyway, I'll add the trailing slash redirect to all other htaccess rules in the plugin next release.
Thanks again!
-
You must log in to post.