Skip to:
Content
Pages
Categories
Search
Top
Bottom

Obligatory trailing slashes on 'name based' permalinks: Add redirect


  • michaeltyson
    Member

    @michaeltyson

    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.

Viewing 2 replies - 1 through 2 (of 2 total)

  • mr_pelle
    Participant

    @mr_pelle

    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!


    mr_pelle
    Participant

    @mr_pelle

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar