Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Search Engine Frienly URL's?

edited January 2006 in Vanilla 1.0 Help
first of all, this script is awesome! what i want to know is if there is something in the making like "Search Engine Friendly" URL's. so instead of: comments.php?DiscussionID=507&page=1#Item_0 it should say comments/507/1/ or something like that.. i see this as one of the biggest missing features in vanilla. any ideas of how this could be done?


  • this topic has been discussed before... i'm not sure what mark's resolution was in the end.
  • lechlech Chicagoland
  • The URLs seem pretty clear-cut. ;-)
  • MarkMark Vanilla Staff
    I will have to take a look into the source and see what it will take to accomplish this. Mod_rewrite is definitely a must-have in order for this to work, but I will also need to change the way that ALL links are written in the application - which should be no small feat. I'll add it to the feature list, because I definitely think this would be a valuable addition.
  • edited August 2005
    In your (newly created, in most installs) .htaccess file in the vanilla base directory...

    RewriteEngine on Options +FollowSymlinks RewriteBase /vanilla/ RewriteRule ^comments/([0-9]+)/([0-9]+)/?$ comments.php?DiscussionID=$1&page=$2 [L]

    Change line three from /vanilla/ to whatever directory your forums are living in, or just leave as / if they're in the base directory.

    It does mess things up a bit tho, as vanilla is built to have no extra directory, and requests only files. As a result, all js and CSS links are invalid. You'll have to add a base link in the head element of your forum to change this.

    <base href="" />
    customising as needed.

    And, as the extensions capability of Vanilla doesn't appear to extend to control classes, you'll have to hard code this into your site (please, please correct me if I'm wrong) :

    controls/Common.Controls.php, line 350.

    Add in your <base /> element just after the <head> tag, and that should all work!

  • MarkMark Vanilla Staff
    edited August 2005
    The extensions capabilities do extend to control classes, just not any classes that are instantiated before the extensions are loaded: like Head, Menu, Panel, Body, Foot, & PageEnd.

    Check out my response in your other thread
  • MarkMark Vanilla Staff
    Oh, and don't I need to go in and change all of the links in the application after implementing all of the above?
  • edited August 2005
    Oh sorry - that's as well as changing all the links...that small thing might help!

    If one was especially clever one could write some Javascript to do it for you; crawl through all the links, check if their hrefs match a regular expression...if so alter the link so that the href is now formatted to a clean url.
    This won't help search engine crawling (as they don't use Javascript) but it will make things nicer for users.

    The only problem being that it might be a bit slow, particularly on older machines.

  • MarkMark Vanilla Staff
    Oh, I'll definitely be having an administrative "use mod_rewrite" switch that makes the application start using different urls. No question about that.
  • Excellent news - another brilliant feature added to the armoury. I like Vanilla :-)

    BTW the mod_rewrite rules for the other likely commands would look something like this :

    RewriteEngine on Options +FollowSymlinks RewriteBase /forums/ RewriteRule ^comments/([0-9-]+)/([0-9-]+)/?$ comments.php?DiscussionID=$1&page=$2 [L] RewriteRule ^categories/?$ categories.php [L] RewriteRule ^categories/([0-9-]+)/?$ ?CategoryID=$1 [L] RewriteRule ^search/([A-Za-z0-9]+)/([A-Za-z0-9-]*)/?$ search.php?PostBackAction=Search&Keywords=$2&Type=$1 RewriteRule ^account/([A-Za-z0-9]+)/?$ account.php?PostBackAction=$1

    where URL would be (in order):
    • /comments/123/45/
    • /categories/
    • /categories/3/
    • /search/Topics/foo/ or /search/Comments/foo/
    • /account/Password/ or /account/Style/
    Etc. They're not too hard to make yourself, but if it helps someone then there you are!

  • edited August 2005
    so, will this make urls like ? because that would be awesome.
  • lechlech Chicagoland
    More like this:

    If a specific category is selected it might look like:
    1 being the category ID

    And if a thread (take this one for example) is selected it would turn out like:
    stripping out the .php and removing all the ? and &'s and turning them into forward slashes that would resemble a proper path.

    In other words, all mod_rewrite is doing is simply breaking down the url into a formatted query apache (or whatever other webserver) understands. Thus allowing your request to get passed via a secondary method while the original (complex looking) one is still available. Behold the power of regular expressions.
  • edited August 2005
    ok, now don't get me wrong here, that is a great addition to this, no doubt about it.

    my question was a thinly veiled request that this be made to include (if it didn't already) the category title and thread title in the url. i know that it is possible, but i have no idea on the complexity.

  • and variations on that theme etc
  • MarkMark Vanilla Staff
    The only problem with that method is that quite often discussions will have the same topic/title. How many times have you seen the discussion topic "hi!". So, if we did it that way, we'd have to do some sort of wacky methodology when creating a discussion topic like:

    1. strip out all non-alpha-numeric characters from the topic and replace spaces with dashes.
    2. check the database to see if that discussion-code already exists
    3. If not, save it. If so, check to see if that code + "-2" exists.
    4. If not, save it. If so, check to see if that code + "-3" exists.
    5. etc etc etc

    That's a bit of overhead, and I would seriously hate to program that. I don't know why, I just would.

    But even then - at the end of the day maybe you're just looking for a hint about what thread you're looking at. I mean, take a look at a discussion url for yayhooray:

    As you can see, they've *also* got the thread id in their url - so that text after the number is really just a visual reference for what the discussion may be about - and that would be pretty easy to pull off.

    I was thinking that I might do something like this...

    Where 648 is the DiscussionID, 1 is the page number, and the rest is just a visual reference.
  • yup, that is the kind of thing, the inclusion of the thread id in the url is not a problem for me, as long as the title is also part of it. as for the category name being in the urls, that wouldn't be as much of a headache (one assumes) as there wouldn't be any 'doublers', so to speak. now, where do i send the cash? :)
  • I think this is a great idea and definitely should be added. The
    Style of url would be preferred.. ideally maybe an option for multiple styles of url in the admin menu?

    Any idea how long it'd take to implement this feature?

  • MarkMark Vanilla Staff
    It's being included in the next revision. As of Friday, I've consolidated and sorted the existing bugs and new features that will be implemented (just about everything on the bugs/enhancement list as of yesterday). Now I will work through the list whenever I have time. Don't have any idea exactly how long it will takes. My answer is always "it'll be finished when it's ready"
  • Sounds good :)
  • We'll just sit here 'til then.. It's still going to be free right?
Sign In or Register to comment.