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

Migrated from Vbulletin 4.2.2 to Vanilla 2.1, Issues with Mod Rewrite (URL)

First of all, I am impressed with Vanilla and how much it has improved, I used it way back but didn't work out as planned but now, wow. I moved from VB 4.2.2 just few hours ago, unfortunately there was an issue with the URL structure. By default Vanilla does redirect old threads to new ones but our installation was using Mod Rewrite and the structure is like this:

http://totseans.com/bbs/threads/24598-The-difference-between-shampoo-conditioner-and-body-wash

Vanilla Routes redirects using the old format, and doesn't redirect.

http://totseans.com/bbs/discussion/24598/the-difference-between-shampoo-conditioner-and-body-wash <-- Vanilla URL Structure

The issue can be fixed via a URL rewrite rule that will take threads and turn it into discussion and take the thread number and place it between //

thread = discussion

24598- = /24598/

Below is the .htaccess which was used in VB:

RewriteEngine on

# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
# RewriteBase /bbs/

# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
# Options -MultiViews

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]

# Check MVC result
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ - [NC,L]
RewriteRule ^(.*)$ - [R=404,L]

Can someone, please help me resolve this issue, it will save us a lot of trouble. Really loving Vanilla.

UnderDogAdrian

Comments

  • peregrineperegrine MVP
    edited July 2014

    mod - rewrite with vanilla works like this.

    Did you try this.

    http://vanillaforums.org/discussion/comment/208595/#Comment_208595

    and if so did it work. and make sure you uncomment the rewrite base !

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

  • lorddfglorddfg
    edited July 2014

    Well, I should mention the above file was from VB,

    This is the current file in which is being used. I added the old file for reference.

    # Original
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /. 
       # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
       # RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    </IfModule>
    

    Reading the link you posted, thanks for the help.

    UnderDog
  • peregrineperegrine MVP
    edited July 2014

    in line 8 above remove the # and make sure it points to the folder where your forum is located

    and make sure the .htaccess file is in that folder where vanilla is installed,

    and set

    in conf/config.php

    $Configuration['Garden']['RewriteUrls'] = TRUE;

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

    UnderDog
  • Both options checked,

    Still, I get 404 for this URL

    [This is the URL which VB Created due to Mod Rewrite Engine]

    http://totseans.com/bbs/threads/24598-The-difference-between-shampoo-conditioner-and-body-wash

    I want a rewrite rule that can convert the above link, into this format.

    http://totseans.com/bbs/discussion/24598/the-difference-between-shampoo-conditioner-and-body-wash

  • peregrineperegrine MVP
    edited July 2014

    .

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

  • 1 - post your newly changed .htaccess.

    Original

    If you modify this file then change the above line to: # Modified


    RewriteEngine On
    # Certain hosts may require the following line.
    # If vanilla is in a subfolder then you need to specify it after the /.
    # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
    RewriteBase /bbs
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]

    2 - is this an example of a link in the body of a comment or in body of discussion

    http://totseans.com/bbs/threads/24598-The-difference-between-shampoo-conditioner-and-body-wash

    Let me clarify this bit:

    This is the default URL structure of Vbulletin which Vanilla can convert:

    http://totseans.com/bbs/showthread.php?t=24598 [See it works fine]

    This is my old URL structure in Vbulletin which is linked throughout the Internet.
    **
    http://totseans.com/bbs/threads/24598-The-difference-between-shampoo-conditioner-and-body-wash**

    [Which I can't convert]

    I am trying to get that to change into this:

    http://totseans.com/bbs/discussion/24598/the-difference-between-shampoo-conditioner-and-body-wash

    or

    this http://totseans.com/bbs/discussion/24598/

    So my old links will redirect correctly.

    3 - what folder is your forum in.

    www.totseans.com/bbs

    4 - and why are you messing with vb , if you already converted.

    I am not messing with it, I am trying to find a way to redirect the modified url which is linked on the websites and cannot be edited or changed manually.

    Plus, I can't write 20K Redirect 301 rules for each article.

    if you would be so kind to answer the 4 items.

    Sorry if this is confusing, I am going to try to be more articulate.

    TL;DR:

    Vanilla redirects fine, however it can't redirect the modified urls which are linked all around the Internet.

    UnderDogperegrine
  • peregrineperegrine MVP
    edited July 2014

    Vanilla redirects fine, however it can't redirect the modified urls which are linked all around the Internet.

    got ya. some folks here are pretty good at rewrite rules. maybe they will chime in. I misunderstood the problem.

    you might also ask at stack exchange web site. since this is not strictly a vanilla questions

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

    UnderDog
  • No problem, I suck at rewrite rules, I am trying to learn them but it will take a while. But thank you for helping out. It means a lot.

    peregrineUnderDog
  • peregrineperegrine MVP
    edited July 2014

    @lorddfg also thanks for specifying your version of vanilla in your opening post/and or title - very helpful for future viewers and responders. I figured I'd try to go the extra mile since you did so.

    this may work. I too am not great at rewrite rules either. but it tested ok for me on my localhost. someone, may have a better solution though.

        # Original
        # If you modify this file then change the above line to: # Modified
        <IfModule mod_rewrite.c>
           RewriteEngine On
           # Certain hosts may require the following line.
           # If vanilla is in a subfolder then you need to specify it after the /. 
           # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
           RewriteBase /bbs
           RewriteRule   ^threads/([0-9]+)-(.*)?$    discussion/$1/$2 
           RewriteCond %{REQUEST_FILENAME} !-d
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
        </IfModule>
    

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

    lorddfgUnderDog
  • Thank you for the effort and yes it works. However, my co-admin actually solved the problem. I requested him to use the Routes feature and things worked out.

    Here is the method if anyone has the same problem.

    Go to:
    http://yourforumaddress/dashboard/routes

    Click Add Route

    In Expression use:

    threads/(\d+)-(.+)

    In Destination use:

    discussion/$1/$2/

    Type

    Permanent (301)

    No obviously this fixes just one issue, this problem affects members, archive links and so on, but once you know the syntax you can easily fix everything else. I will update this post with full redirects once I have finished fixing things.

    Thank you for your help.

    Also, if you have this same issue, might I suggest that you plan your upgrade ahead of time and if you're stuck like me, do this:

    Dump all sitemaps, use Google Webmaster Tool, send a new sitemap and then work on fixing the old links. This will hopefully keep things rolling, as long as you don't get 404 errors, you're fine.

    peregrineUnderDogLincAdrian
  • peregrineperegrine MVP
    edited July 2014

    you also may have won the solutionsayer badge from the @linc

    which leads to a few followup questions, if anyone knows....

    Q1. is it better to use routes within vanilla or to use a rewrite within .htaccess

    one advantage I see to routes is that the .htaccess could get rewritten when you upgrade,
    but i wonder if routes is a bit slower.

    aside from the 301 which could also be added in the .htaccess and d+ vs 0-9 - which is not my question here.

    Q2. Is discussion/$1/$2 better or worse then discussion/$1/$2/ and what advantage does one have over the other.

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

    UnderDog
  • LincLinc Detroit Admin

    Routes was exactly the right solution; thanks for sharing the pattern to use.

    peregrineUnderDog
  • peregrineperegrine MVP
    edited July 2014

    thank you to anyone taking the time to provide an explanatory answer to the question of the trailing slash versus no trailing slash at the end of the Destination pattern.

    Q2. Is discussion/$1/$2 better or worse then discussion/$1/$2/ and

    • what advantage does one have over the other.

    Also, what is the exact reasoning why routes is the best solution, other then it is compartmentalized in vanilla.

    I am trying to grok why??

    version 2.1

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

    UnderDog
  • x00x00 MVP
    edited July 2014

    The main thing with trailing slash or not is to stick with one. Constituency is the more important thing. Also some server default will automatically redirect one to the other so you need to be aware of that, to prevent extra redirects.

    I think with vanilla without is best as that is the most consistent.

    grep is your friend.

    peregrineUnderDoglorddfg
  • peregrineperegrine MVP
    edited July 2014

    @x00 said:

    The main thing with trailing slash or not is to stick with one. Constituency is the more important thing. Also some server default will automatically redirect on to the other so you need to be aware o that.
    I think with vanilla without is best as that is the most consistent.

    thank you x00 that is precisely why I thought without the trailing slash might be more correct. but I am ignorant on SEO and other things, so I thought that might possibly some reason I was unaware of to add the slash. My other thought was that in vanilla adding the trailing slash in general vanilla might break things that get appended on with a #

    e,g, #last , etc. or something embedded in wp.

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

  • Yes you will get a lot of nonsense with with "SEO experts" though. Don't believe everything you hear. SEO has a lot of speculative behavior, but if you spent too much time on that wouldn't be spending time on the content side which is more important.

    In thin case it is really about consistency, and returning a canonical url with a OK (200) status. There is no evidence that generally one is better than the other,

    grep is your friend.

    peregrineUnderDog
  • peregrineperegrine MVP
    edited July 2014

    thank you @x00 - I find every one of your posts are extremely valuable - you are the master in my book!

    You are a consistently fantastic source of information. especially when it comes down to the nitty-gritty and when there appears to be no solution in sight - you manage to come up with one that perfectly matches ones needs.

    Another round of Applause to you. you are the MVP of MVP's

    I know you are pretty humble, just wanted to express my appreciation.

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

Sign In or Register to comment.