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

XF 1.4 Help with SMF redirects

#1
Hi,

I have been checking the redirect posts for SMF.

the difference against others is that I used the pretty URLs addon
https://code.google.com/p/prettyurls/

Since looks I'm very bad with regex and htaccess, I bow my head down, and in defeat after 4+ hours, I come here asking for help.

Since I didn't use the preserve IDs, I plan on using and modify this add-on
https://xenforo.com/community/resources/redirection-scripts-for-vbulletin-3-x.264/

I already added some preprocessing that checks in SMF database for info regarding

My first problem (and the one that was "easy") is with members.

What should I add to .htaccess to redirect to member.php? it needs something in the form of member.php?u=1 for example, but I can't make it work.

Any recommendations?
 

Jake Bunce

XenForo moderator
Staff member
#2
The important thing is to redirect threads.

Your old thread URLs appear to be using slugs instead of ids. It will be necessary to write a script to map the slug to an id. It will be similar to this script for MyBB:

https://xenforo.com/community/threads/redirecting-mybb-urls.28809/page-2#post-692873

Your forum redirects will be similar since they also use slugs.

Your member redirects use ids so we just need to map the id. Add these rules to the top of the .htaccess file at http://hablajapones.org/foro/profile/ :

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)($|&)
RewriteRule ^$ http://omarbazavilvazo.com/hablajapones/prueba/member.php?u=%2 [R=301,L]
Then upload these scripts to http://omarbazavilvazo.com/hablajapones/prueba/ (where XF is):

https://xenforo.com/community/resources/redirection-scripts-for-vbulletin-3-x.264/

That should do it.
 
#3
My master!! :) ley me try it!

I already did the php to get the thread title to the old id, the problem for me now are the htaccess.

Let me try and let you know

Thanks!
 
#5
Seems this did the trick (i don't know why though...)

Code:
RewriteEngine on

# Rules for: members
RewriteRule ^(profile)/?$ ./member.php?u=$1 [R=301,L]
if you have a better recommendation let me know

in the folder /foro i will put all htaccess and that vb script to redirect to real location

Let me try threads and forums :)

Thanks for your help!

EDIT: when i put [R=301,L] instead of [L,QSA] all redirects are screwed on my localhost :S any idea why?
 
Last edited:

Jake Bunce

XenForo moderator
Staff member
#6
But profile is not a directory.

Everything is located at
http://hablajapones.org/foro

There is a htaccess that handles urls in the form /profile/u=123, but somehow I can't use it to use members.php

How to change the regex to handle not only u=123 but profile/u=123?
Revision to previous instructions for member links:

Add these rules to the top of the .htaccess file at http://hablajapones.org/foro/ :

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)($|&)
RewriteRule ^profile/$ http://omarbazavilvazo.com/hablajapones/prueba/member.php?u=%2 [R=301,L]
Then upload these scripts to http://omarbazavilvazo.com/hablajapones/prueba/ (where XF is):

https://xenforo.com/community/resources/redirection-scripts-for-vbulletin-3-x.264/

That should do it.
 

Jake Bunce

XenForo moderator
Staff member
#7
in the folder /foro i will put all htaccess and that vb script to redirect to real location
That shouldn't work.

The PHP redirect scripts need to go in the same directory as XenForo. The rewrite rules forward the appropriate links to those scripts on the new domain in your XenForo directory.
 

Jake Bunce

XenForo moderator
Staff member
#8
EDIT: when i put [R=301,L] instead of [L,QSA] all redirects are screwed on my localhost :S any idea why?
Use [R=301,L] like in my instructions.

I assume the user_ids are different between SMF and XF? In that case it is necessary to capture the id in the source URL and pass it to the redirect script which does the mapping. My instructions do this.

Your other rewrite rule that you proposed might accidentally work, but it's not correct. Your rule fails to extract the id from the query string, but the [L,QSA] would preserve the original query string. I am not sure if this would end up combining the two 'u' parameters or overwrite one with the other. It might end up working, but it's wrong.
 
#9
Before anything else, thanks for your help!!

I assume the user_ids are different between SMF and XF?
Yeah. The IDs are different, that's why I will use the vb script to map the oldid->map id.

Ok, here is a overall description of how I will do the migration (in the first days of january or sooner, waiting for a newer migration script and some XenForo customization for kanji seaches I want to implement among with the merge)

For now i have:

hablajapones.org <- portal
hablajapones.org/foro <- SMF (is a folder)

So all urls are like hablajapones.org/foro/something...

How i want to put now is:
hablajapones.org <- XenForo portal (Widget Framework for now, maybe someday CTA or another portal)
hablajapones.org/index.php?forums/ <- XenForo forums for example
hablajapones.org/foro <- empty folder with .htaccess and vb redirection scripts.

Below are the RewriteRules that I got working, but can you check them? Maybe your suggestion is going to be better of what I'm doing.

Members:
http://hablajapones.org/foro/profile/?u=16
Expecting: u=<number>
Code:
# Rules for: members
#RewriteRule ^(profile)/?$ ./member.php?u=$1 [L,QSA] <-- OLD one I had, changed it to your recommendation
RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)($|&)
RewriteRule ^profile/$ ./member.php?u=%2 [R=301,L]
Posts:
http://hablajapones.org/foro/notici...favor-de-registrarse-nuevamente/msg44211/#new
http://hablajapones.org/foro/notici...-de-registrarse-nuevamente/msg42375/#msg42375
Expecting: p=<number>
Code:
# Rules for: posts
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/msg([0-9]*)/(#msg[0-9]*)?$ ./showpost.php?p=$3 [L,QSA]
Topics:
http://hablajapones.org/foro/noticias-importantes/hablajapones-version-4-comienza-el-proyecto/
http://hablajapones.org/foro/noticias-importantes/hablajapones-version-4-comienza-el-proyecto/15/
Expecting: t=<string>.<number>
Code:
# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./showthread.php?t=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./showthread.php?t=$2.$3 [L,QSA]
Boards:
http://hablajapones.org/foro/noticias-importantes/
Expecting: f=<string>
Code:
# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./forumdisplay.php?f=$1 [L,QSA]
I already modified forumdisplay.php and showthread.php to receive a string and do the string->id mapping querying the SMF database and return a numeric ID.

Any reason why I can't leave member.php, forumdisplay.php, showthread.php and showpost.php in the same folder as .htaccess? (/foro) ?
On my WAMP installation the forward seems to be working fine, since the vb redirection script grabs the url from the XenForo Installation

Also, I was leaving the [L,QSA] for the time being, but aiming to change those for [R=301,L] once I uploaded it to my server.

Thanks!