XF 1.4 Rewrite rules help

clubpromos

Active member
Hi,

There are a couple of rewrite rules that I am struggling with after migrating, maybe someone has a simple answer:

1. Permanently redirect example.com/forum/forum/external.php?type=RSS2 to https://www.example.com/forum/forums/-/index.rss

2. Permanently redirect /forum/forums/[forum_name]/index2.html to /forum/forums/[forum_name]/page-2
And so on for all forums paginations (index3.html > page-3 etc...)
This one is the last step of redirects from VB that is missing for me.

Thanks
 
Add these rules to the top of the .htaccess file in your /forum directory:

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)type=RSS2($|&)
RewriteRule ^forum/external\.php$ /forum/forums/-/index.rss? [R=301,L]

RewriteRule ^forums/([^/]+)/index([0-9]+)\.html$ /forum/forums/$1/page-$2 [R=301,L]
 
@Jake Bunce thanks very much for offering to help, much appreciated. I ended up creating a php file which works just fine :). Not as clean but it works.

However I also noticed that links to single posts are not redirected and end up in 404's. The pattern is:
1. Old links to single post look like this: http://www.example.com/forum/680054-post401.html Where [680054] is the actual post ID. After the dash (-post....) is the post number in the specific thread but I think that we can bypass it as it can be anything.
2. Xenforo post link would be (if I'm not mistaken) : https://www.example.com/forum/posts/680054

If you've got a minute to let me know if this is possible it would be of tremendous help as Google is eating up my links at a crazy pace right now....
 
Building on my previous post...

Add these rules to the top of the .htaccess file in your /forum directory (added the last line for posts):

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)type=RSS2($|&)
RewriteRule ^forum/external\.php$ /forum/forums/-/index.rss? [R=301,L]

RewriteRule ^forums/([^/]+)/index([0-9]+)\.html$ /forum/forums/$1/page-$2 [R=301,L]

RewriteRule ^([0-9]+)-post[0-9]+\.html$ /forum/posts/$1/ [R=301,L]
 
Thanks @Jake Bunce this worked beautifully!

I'm sorry to have another request... as I've noticed another set of odd links that Google is trying to access and were coming from VBSEO and the Xenforo redirection script is not redirecting them as it should (I guess, I don't even know where these were).
I think that this one is really complicated and I don't know if it's even possible with mod_rewrite (which would suck but so be it)

1. Explanation: I had links link /forum/old-forum-name/old-thread-name-t12345-post123456.html that are redirected to /forum/forums/new-forum-name.id/old-thread-name-t12345-post123456.html with the migration script. Of course, this ends up in 404's.

2. Technically it could be redirected to the xenforo link: /forum/posts/123456 but that would be a conflict with the rule set before (
RewriteRule ^([0-9]+)-post[0-9]+\.html$ /forum/posts/$1/ [R=301,L]), isn't it?

3. Then my other thought is that it could be redirected to the thread itself like on account that t12345 is in the URL. So the redirect would be from /forum/forums/new-forum-name.id/old-thread-name-t12345-post123456.html to /forum/forums/new-forum-name.id/old-thread-name-t12345.html then the migration redirects take it from there correctly as far as I can tell.
I'm not sure how this would be in conflict with the aforementioned rewrite rule.

Once I'm done I think that I'll put this all plus what I did on my own in a thread so that others don't go through what I'm going through right now...
 
1) That redirect you describe should not be the result of the rules I posted. Look in the web root directory for redirect rules that might be causing this. My rules should have been placed in the /forum directory.

2) That is not a conflict, no.

3) I have added another line for the new post URL example you posted (/forum/forums/new-forum-name.id/old-thread-name-t12345-post123456.html):

Add these rules to the top of the .htaccess file in your /forum directory (added the last line for additional post URL):

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)type=RSS2($|&)
RewriteRule ^forum/external\.php$ /forum/forums/-/index.rss? [R=301,L]

RewriteRule ^forums/([^/]+)/index([0-9]+)\.html$ /forum/forums/$1/page-$2 [R=301,L]

RewriteRule ^([0-9]+)-post[0-9]+\.html$ /forum/posts/$1/ [R=301,L]

RewriteRule ^forums/[^/]+/[^\./]+-t([0-9]+)-post([0-9]+)\.html$ /forum/posts/$2/ [R=301,L]
 
Top Bottom