HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.


  • R_JR_J Ex-Fanboy Munich Admin

    Depending on where you want to change it, the solution might be to simply create a file /conf/bootstrap.before.php with the following content:

    if (!function_exists('discussionUrl')) {
        * Return a URL for a discussion. This function is in here and not functions.general so that plugins can override.
        * @param object|array $discussion
        * @param int|string $page
        * @param bool $withDomain
        * @return string
       function discussionUrl($discussion, $page = '', $withDomain = true) {
           $discussion = (object)$discussion;
           $name = '.';
           $result = '/discussion/'.$discussion->DiscussionID.'/'.$name;
           if ($page) {
               if ($page > 1 || Gdn::session()->UserID) {
                   $result .= '/p'.$page;
           return url($result, $withDomain);

    While that should be perfectly okay, it would be cleaner to create a plugin for that. You would have to create a plugin with an emply plugin class and add that function below the class definition.

  • You are great!

    BTW, how to change the text "discussion" of permalink to other text like thread?

    Thanks again.

  • I spy with my little lens

    $result = '/thread/'.$discussion->DiscussionID.'/'.$name;
  • No luck with this treatment.☹️ It cause Page Not Found

  • It seems not working.

  • R_JR_J Ex-Fanboy Munich Admin

    Blind copy and paste without understanding oftentimes do not yield the expected results... As the above linked discussion explains, that route makes a "/discussion/123" available as "/d/123". Why did you expect it also makes a discussion available as "/thread/123"?

    You should have put some brainwork in that. But hey, this is a help forum so here is the brainwork already done for you: that is the expression that you need ^thread/([\d]*)

  • Thank again.😅

    The example I show to you was a brand new forum that I just created.

    I replaced both "d" to "thread" on my live forum but still no luck.

    I saw you taught me change to ^thread/([\d]*) and then I try it seems successful.

    But when I clicked the topic the url bar changed to /discussion/ instead of / thread/ like https://xxx.com/discussion/12#latest

    Thanks for your patient!

  • R_JR_J Ex-Fanboy Munich Admin

    The route is a regular expression where "\d" is for decimal numbers (which is the discussion id in this case)

    Depending on where you want to change it, the solution might be ...

    The route simply is a redirection from the (technically) false "thread" or "d" or whatever to the (in Vanilla terms) correct "discussion". Changing this real address is way more complicated and might not even be possible.

    My approach would be to create a ThreadController that extends the DiscussionController and try to hook somewhere in the dispatcher to call the ThreatController which then needs to intercept the request and re-route calls to the DiscussionController, but I would expect numerous problems with that.

  • Noted and thanks!

  • @tennyy While I delay in making the super plugin for Vanilla to manage Urls like a Boss, you can get some deep ideas from here


Sign In or Register to comment.