XF 1.1 URL Rewrite Rules questions

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]

*Thread*
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!
 
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.
 
Is it not possible to redirect vbSEO permalinks and showpost links to vB or Xenforo ?

This is the vbSEO link:
http://www.site.com/forum-13/thread-1456/#post3529


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:
http://www.site.com/forum-13/thread-1456/#post3529
to
http://www.site.com/showthread.php?t=3529
?

Thanks!
 
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:

...

As for the postids... if a postid is given in the URL then it is redirected to the correct page with an anchor. I just tested this myself. For example:

original: showpost.php?p=118757
redirect: index.php?threads/thread-title.9013/page-2#post-116535

original: showthread.php?p=118757#post118757
redirect: index.php?threads/thread-title.9013/page-2#post-116535

When the URL contains a postid you can make a correct redirect like this. But the postid must be part of the query string. If the postid is only specified as an anchor then the server won't see it. As Mike suggested, this may be possible with javascript.

Those are default vB URLs though, not vBSEO.
 
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.



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
 
Top Bottom