Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

I need help changing vanilla default route

For some very important reasons that has to do with integration, I need to change the vanilla default discussion route from
to something like
I have tried changing the routes from the dashboard->Routes (DefaultController and DefaultForumRoot), but when I change them, it breaks the forum.


  • Do you want to change the defaultroute or the destination url.

    two different things.

    most likely you want to change the destination url.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • routes are not explicit in vanilla yet. There is an implicit pattern mapped to the controller.

    dashboard -> Routes describes redirects rather then actual formally define reversible routes.

    grep is your friend.

  • There is a DiscussionUrl function which can be predefined. It may not always be adhered to. However if you have a route and a 301 redirect this could be a reasonable solution.

    grep is your friend.

  • Defaultroute or destination, I just want to change


  • I just want to change the url of discussions

  • I just want to change the url of discussions

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    The answer is already there, but no step by step how to. You have to change the route. That should be possible by using the RewriteRules of your server. Search the internet for RewriteRule and htaccess to get a basic understanding. Maybe someone who knows about that better than me can support you later on, but you really should have a minimal knowledge.

  • xm1xm1 New
    edited October 2015

    I know I can use htaccess to do something like:
    RewriteRule ^custom/([0-9]+)/([a-zA-Z0-9_-]+)/?$ discussion/$1/$2
    This infact works.
    Adding this code in my htaccess file makes it possible for me to visit the discussion at forumurl/discussion/123/post-slug using forumurl/custom/123/post-slug.
    Now the challenge is how do I replace the urls of all the discussions in the forum with my new url pattern, basically replacing the "discussion" in the urls to "custom".
    I don't think I can achieve that with htaccess. can I?

  • xm1xm1 New
    edited October 2015

    Now I've been able to redirect all requests to forumurl/discussion/* to forumurl/custom/* using routes.
    But I need to change urls of all discussions to forumurl/custom/*
    can the DiscussionUrl function @x00 mentioned do that for me? and where is this function located?

  • @xm1 said:
    can the DiscussionUrl function x00 mentioned do that for me? and where is this function located?

    create a file /conf/bootstrap.after.php


    <?php if (!defined('APPLICATION')) exit();
    function DiscussionUrl($Discussion, $Page = '', $WithDomain = TRUE) {
       $Discussion = (object)$Discussion;
       $Result = '/custom/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name);
       if ($Page) {
          if ($Page > 1 || Gdn::Session()->UserID)
             $Result .= '/p'.$Page;
       return Url($Result, $WithDomain);

    as this is not full proof you may want to also 301 redirect /discussion to /custom generally this function is used more than not.

    grep is your friend.

  • Thanks @x00 I think I've achieved what I want.

  • xm1xm1 New
    edited November 2015

    Now there is a challenge. Everything works well on discussions with all of its comment in one page, If discussion comments is up to 2 pages, when I go to page 2 I get only the discussion title, the pagination and the editor. Non of the comments that are supposed to display in page 2 will show up. When I manually change the url in the browser to discussion it works.

Sign In or Register to comment.