1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 URL Rewrite Rules questions

Discussion in 'Installation, Upgrade, and Import Support' started by Moddis, May 14, 2013.

  1. Moddis

    Moddis Active Member

    I am migrating over from Vb with vbSEO installed to XenForo.

    Instead of using other suggested methods of using rewrite rules to redirect vbSEO links to VB Links and then have a script redirect those url's to XenForo links. As a backup, in case someone has an old VB link(non vbSEO), I will use the script Here to redirect those links to XenForo. I think this method will save me server resources not having to redirect 2x and i was also afraid it might hurt with Google having a double redirect to final destination.

    Anyway, I already wrote 3 rules that seem to work fine but i do have a few questions before I go and do the dozens of other links...

    *Forum Path*
    vbSEO Setup: [forum_title]-[forum_id]
    RewriteRule ^[^/]+-([0-9]+)/?$ /forums/$1/ [R=301,L]

    vbSEO Setup: [forum_title]-[forum_id]/[thread_title]-[thread_id]/
    RewriteRule [^/]+-[0-9]+/[^\.]+-([0-9]+)/?$ /threads/$1/ [R=301,L]

    *Thread Page*
    vbSEO Setup: [forum_title]-[forum_id]/[thread_title]-[thread_id]/index[thread_page].html
    RewriteRule [^/]+-[0-9]+/[^\.]+-([0-9]+)/index([0-9]+)\.html /threads/$1/page-$2 [R=301,NC,L]

    1. Are there any advantages/issues of using one over the other?
      1. [0-9]+ OR [\d]+
      2. [^\.]+ OR . OR [A-Za-z0-9-]+
    2. The links I redirect vbSEO links to (/threads/$1/) also seem to have an internal redirect to: /threads/thread_title-$1/. Would it makes sense to redirect directly to that (again possibly helping with google or server load?)
      1. *Example* (vbSEO URL: [forum_title]-[forum_id]/[thread_title]-[thread_id]/) Use:
        1. RewriteRule [^/]+-[0-9]+/([^\.]+)-([0-9]+)/?$ /threads/$1.$2/ [R=301,L]
      2. Instead of:
        1. RewriteRule [^/]+-[0-9]+/[^\.]+-([0-9]+)/?$ /threads/$1/ [R=301,L]
    I know urls are something not to be messed with once set up so im just trying to do it properly from start. Thanks for any suggestions!
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    1) Either way works. I prefer to specify delimiters such as "not a period" rather than specify all allowed characters.

    2) Yes, XenForo has internal redirects to enforce the canonical URL for important routes like threads. That is normal. Your rewrites specify only the id, then XenForo does the canonical. This is not a problem.
    Moddis likes this.
  3. Moddis

    Moddis Active Member

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Moddis likes this.
  5. Moddis

    Moddis Active Member

    Cool, thanks!
  6. Moddis

    Moddis Active Member

    Is it not possible to redirect vbSEO permalinks and showpost links to vB or Xenforo ?

    This is the vbSEO link:

    I tried the following with no luck:
    RewriteRule #post([\d]+) /showthread.php?p=$1.html [R=301,NC,L]

    I found out that he "#post3529" part of the URL is called a a URL Fragment, and it is never sent to the server, thus, can't match against it because it's simply not there. So the regex: #post([\d]+) will never match. There is no way to get around this without some javascript trickery.

    Has anyone encountered this issue and is there in fact now way to redirect:

  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Correct. Anchors are not sent to the server so you can't rewrite them.

    Some vB URLs contain the postid as a GET parameter and not an anchor, and those can be redirected. To quote an old post of mine:

    Those are default vB URLs though, not vBSEO.
    jeffwidman likes this.
  8. Moddis

    Moddis Active Member

    Thanks for confirming this. Ill go ahead and drop it so I dont drive myself crazy trying to figure it out.

    I guess the only vbSEO permalink I can salvage is this: http://www.site.com/3529-post9.html

    Using: RewriteRule ^([\d]+)-post[\d]* /showthread.php?p=$1.html [R=301,NC,L]

    And then use the provided script to redirect that to XenForo links: http://www.site.com/threads/thread_name.387/#post-3529

Share This Page