Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Easy ways to change the URL from /discussion/?

edited April 2010 in Vanilla 2.0 - 2.8
Currently, the URL to a discussion is as the format of:

http://vanillaforums.org/discussion/11013/post-discussion-button

It works well for generic discussion purposes. However, as I am using Vanilla 2 for a slightly different purpose (more towards Classified Ads as a matter of fact), the URL isn't very desirable for me for SEO purposes.

I actually wanted it to be of something like:

http://domain.com/item/11013/dell-laptop

I thought of two ways that I could possibly change it. First, by renaming the Controllers/Modules and force it to load with a different name. A second way would be via modifying the default .htaccess and somehow map /item/ onto /discussion/ instead. Not sure if both are possible as I have not done my fair share of probing yet.

Just wondering if there could be a third and easier way? I thought Routes might be relevant but I couldn't find more information about how to use it.

Any suggestions are welcomed. :)

Comments

  • TimTim Operations Vanilla Staff
    .htaccess would certainly help you to map /item/ onto /discussion/

    I messed around for about an hour with a plugin that would do some of this and decided that it would be *possible* but not *easy*, if that makes any sense. The real issue is that even though its quite simple to make a call to /item/ trigger the DiscussionController, its much more complex to replace all the hyperlinks in the view so that they too point to /item/ and not /discussion/.

    I think your best bet in terms of value for your time would be to use .htaccess to translate /item/ into /discussion/ and then just live with the fact that the links are still going to point to /discussion/ until they're clicked.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Seems vanilla routing is order (when i figure out how it works ill let you know for urls with parameters). About the links thing, it seems like it should be a reverse routing system, so if you have a route for that link the anchor function should change the link accordingly.

    @Mark just tagging you here to see what your views on routing with the anchor tag obeying routes too if they apply.
  • This is probably one of those times when it would make sense to stop trying to bend Vanilla 2 to your will and just create a new Garden Application instead...
  • Shhh Stash, when did you get so logical :P Everyone knows you should just keep hacking away until something sorta fits.
  • NickENickE New
    edited April 2010
    this shouldn't be very hard at all. Make some new routes:item/:num/:alphanum -> discussion/$1/$2 and item/:num -> discussion/$1
    then, in applications/vanilla/views/* replace all instances of /discussion/'.$Discussion->DiscussionID with /item/'.$Discussion->DiscussionID (should be in like 3 or 4 files)

    (we need like an inline code tag or something)
  • MarkMark Vanilla Staff
    @Tim and I were discussing even doing something with the Anchor() function to make it reverse the routes. It's a bit of a hack, but possible to do with a plugin...
  • That would be quite cool, but what about lossy redirects?
  • @Tim Yea I might do .htaccess as a temp solution, and look into changing everything else later. :)

    @NickE I don't understand the routing bits. Am I supposed to set it up in the Dashboard or are they parameters for .htaccess?

    @Mark I was just wondering, wouldn't it be better for the URL to be in these formats?

    domain.com/[categoryname]
    domain.com/[categoryname]/[id]/[discussionname]

    instead of

    domain.com/category/[categoryname]
    domain.com/discussion/[id]/[discussionname]

    I mean it would be easy for end users to just configure accordingly in the Category Settings and there is no need to delve into Anchor or Reverse Routing, which sounds very complicated to me. Plus I think the SEO of the new URLs would be much better too. :)
  • Routes are in the dashboard. You should be able to do this without messing about with .htaccess files at all.
  • MarkMark Vanilla Staff
    @jjsee - For a variety of reasons, that wouldn't work with the platform. One big reason is that categories are not required (ie. some forums don't use categories at all).
  • People seem to be tied up on this url seo, it really makes very little difference at all to your seo.
  • @Mark There is always the default category isn't it? The All Discussion/General category. There is already an exception made for that in which the URL is domain.com/discussions instead of domain.com/category, should be pretty straight forward to also allow that to be configurable as well following these changes.

    @garymardell Maybe SEO isn't the strong point here. But the thing is, allowing the URL to be customizable would make Vanilla a lot more versatile as a multi-purpose platform. I was just reading on another discussion here in which the author wanted to build a dating website based on Vanilla. And my application of Vanilla is not exactly as a forum too. Why restrict such a wonderful platform to just forums when it could truly blossom as just anything with such a simple change?

    The URL code is already built-in, so it's really just about allowing the category's URL code to be fully utilized.

    I understand that it is possible to customize the URL right now by going through the files, but from a end-user who is not very technical's (which on an average case is about 80% of the population) standpoint, to be able to just configure everything in the Admin Panel is a superb feature.

    Anyway just my 2 cents. :)
  • Just thought I would elaborate somemore on the versatility concept.

    Given that I can now set up categories in the format that I suggested:

    domain.com/categoryname
    domain.com/categoryname/id/discussionname

    I can now create a category called blog, and I can change the entire display of the category in my theme, and make it looks like an actual blog. I can create a category called page, and it too can look very different from the rest of the categories.

    And these can be done under Themes by setting conditional checks, which is great for users who are not as highly technical as most of you here are. Although Applications is itself designed for such multi-purpose, customizing Applications would be out of league for a lot of users.

    Anyway I do understand what some of the limitations are, like how the way modules and themes are related to each other via URLs would probably be a major problem. Still would be great if my idea can be tweaked somewhat into a workable model. :)


  • rookie

    @rookie said:

    Just thought I would elaborate somemore on the versatility concept.

    Given that I can now set up categories in the format that I suggested:

    domain.com/categoryname
    domain.com/categoryname/id/discussionname

    I can now create a category called blog, and I can change the entire display of the category in my theme, and make it looks like an actual blog. I can create a category called page, and it too can look very different from the rest of the categories.

    And these can be done under Themes by setting conditional checks, which is great for users who are not as highly technical as most of you here are. Although Applications is itself designed for such multi-purpose, customizing Applications would be out of league for a lot of users.

    Anyway I do understand what some of the limitations are, like how the way modules and themes are related to each other via URLs would probably be a major problem. Still would be great if my idea can be tweaked somewhat into a workable model. :)

    I am curious about the method you use. Right now if i want to achieve such i would have to manually search and replace all instances in the core files. I am wondering if there is a better way as I do not understand and trust the other methods yet. thanks.

Sign In or Register to comment.