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.

[Solved] 301 redirect help with regex needed after wp embed

edited March 2011 in Vanilla 2.0 - 2.8
I am getting a TON of bots and users with 404 errors after embeding my forums.

I used the same directory name but the # in the path is what is breaking it.

eg: it went from -> http://mysite.com/forum/discussion/15074/test-topic
to -> http://mysite.com/forum/#/discussion/15074/test-topic

I thought maybe adding a redirect to my htaccess may fix it but I am not the best at regex. Does this look right?

RedirectMatch http://mysite.com/forum/\.(.*)$ http://mysite.com/forum/#/$1



  • edited March 2011
    I figured out how to handle this in WordPress with the Redirection Plugin
    I'll share what I did in case anyone else runs into it

    First - I saw some old phpBB entries coming in with the pattern like this (which I was using before porting over to vanilla)

    To fix old phpbb links to new vanilla links
    * Original Source - http://freakscene.net/forum/viewtopic.php?f=16&t=13833&start=805
    * Target - http://freakscene.net/forum/#/discussion/13833/

    Regex used to redirect it
    - Source - /forum/viewtopic(.*)t=(\d*)&(.*) - Target - /forum/#/discussion/$2/

    I added a second one to catch those that don't have post start info (no start)
    - Source - /forum/viewtopic(.*)t=(\d*) - Target - /forum/#/discussion/$2/

    My pre to post embed vanilla links (with the #) I used this
    - Source - /forum/discussion/(.*) - Target - /forum/#/discussion/$1

    And for direct comment links in vanilla
    - Source - /forum/discussion/comment/(.*) - Target - /forum/#/discussion/comment/$1

    And for profile links in vanilla
    - Source - /forum/profile/(.*) - Target - /forum/#/profile/$1

    Anyway, it may give you a starting point if you are hitting this sort of thing.

    The ones I listed above & addressed were showing up as 404 errors after embedding (mostly from search engines and old incoming links) but this fixed it.

    If there is a more graceful pattern or better way to do it I welcome it :)

  • I edited the Vanilla Forums Wordpress plugin file vanilla-forums/widgets.php and modified the line

    $link_url = vf_get_link_url($options);

    to hard code my path.

    Graceful, no. Easy, yes.
  • Nice :)

    The majority of the links I had to correct were from external sources so I the redirect worked great for me. While I was in there I adjusted some internal ones based on the patterns as well.
Sign In or Register to comment.