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

XF 1.2 Find/Replace URLs in Posts (Regex/VBSEO)

#1
Morning,

I'm in the middle of finalising a migration from vBulletin v4.2.2 which was utilising the defunct VBSEO plugin, it also includes a domain migration. I want to utilise Kier's Find & Replace plugin to replace the old internal links.

I could leave them linking off-site and having the .htaccess rewrite bounce it back, but it's an ugly solution and I'd rather get the job done properly.

The old VBSEO structure:
Code:
http://domain.tld/category-name/00-thread-name.html#post00
Link example:
Code:
http://accordownersclub.co.uk/7th-generation-accord/4621-new-member-2-4-type-s-2.html#post35539
Xenforo deploy:
Code:
http://hondakarma.com/threads/4621/#post-35539
Migrating the thread name isn't important as I know XF will redirect fine with just a thread ID. The only part I'm not sure on, is when matching a specific post in a thread using an ID, if the post linked isn't on the first page, XF doesn't seem to redirect automatically to the correct page containing that post. Basically just relying on browser's native navigation by HTML "id" attribute.

Any help appreciated, Regex is not my friend.
 

EQnoble

Well-known member
#3
Morning,

I'm in the middle of finalising a migration from vBulletin v4.2.2 which was utilising the defunct VBSEO plugin, it also includes a domain migration. I want to utilise Kier's Find & Replace plugin to replace the old internal links.

I could leave them linking off-site and having the .htaccess rewrite bounce it back, but it's an ugly solution and I'd rather get the job done properly.

The old VBSEO structure:
Code:
http://domain.tld/category-name/00-thread-name.html#post00
Link example:
Code:
http://accordownersclub.co.uk/7th-generation-accord/4621-new-member-2-4-type-s-2.html#post35539
Xenforo deploy:
Code:
http://hondakarma.com/threads/4621/#post-35539
Migrating the thread name isn't important as I know XF will redirect fine with just a thread ID. The only part I'm not sure on, is when matching a specific post in a thread using an ID, if the post linked isn't on the first page, XF doesn't seem to redirect automatically to the correct page containing that post. Basically just relying on browser's native navigation by HTML "id" attribute.

Any help appreciated, Regex is not my friend.

First of all, welcome to the community.

While regex happens to be a friend of mine there is some work involved in this, I am a bit tired and going to sleep in a few. I probably need more info but if you like I can get back to you with what I need to know if anything tomorrow when I wake up?


Ant
 
#6
Thanks for that, I assume that expression will only match URLs that include the post ID anchor on the end, right?

Working backwards, would the below then cover the thread links themselves? ...and if not, if it's not too much trouble could you fix my attempt? :D

Code:
#http://accordownersclub\.co\.uk/[a-zA-Z0-9_\-]+/([0-9]+)-[a-zA-Z0-9_\-]+\.html#siU
Code:
http://hondakarma.com/threads/\1/
Many thanks.
 

Jake Bunce

XenForo moderator
Staff member
#7
Thanks for that, I assume that expression will only match URLs that include the post ID anchor on the end, right?

Working backwards, would the below then cover the thread links themselves? ...and if not, if it's not too much trouble could you fix my attempt? :D

Code:
#http://accordownersclub\.co\.uk/[a-zA-Z0-9_\-]+/([0-9]+)-[a-zA-Z0-9_\-]+\.html#siU
Code:
http://hondakarma.com/threads/\1/
Many thanks.
winner :)
 

audiokid

Active member
#13
Cool, that helped but it doesn't rebuild the link unless I edit and save. ? Do I need to rebuild all the forum posts now? It still have those tags. Can I remove them now?
Plus, it doesn't stream. Is there something I can do to stream SC now. Thanks guys! :)
 

Jake Bunce

XenForo moderator
Staff member
#14
I have another that I would like to fix! Can we get these Soundcloud links working again? Streaming :)

[SC]https://soundcloud.com/audiokid/mozart-3movement-piano-1[/SC]
Cool, that helped but it doesn't rebuild the link unless I edit and save. ? Do I need to rebuild all the forum posts now? It still have those tags. Can I remove them now?
Plus, it doesn't stream. Is there something I can do to stream SC now. Thanks guys! :)
Now that you have created the media site for soundcloud you just need to update old posts to use the new [media] tag in XenForo.

Use this addon:

http://xenforo.com/community/resources/post-content-find-replace.1549/

Quick Find: [SC]https://soundcloud.com/

Regular Expression: #\[SC\]https://soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)\[/SC\]#siU

Replacement String: [media=soundcloud]\1[/media]

That should do it. Backup first.
 

Jake Bunce

XenForo moderator
Staff member
#17
That worked like a charm. But now when I add a new media like this:
https://soundcloud.com/audiokid/better-by-morning-kultube

it only created the link as it does here too. .

If use the embed option in the editor, it produces an error?
Confirm these settings:

http://xenforo.com/community/threads/add-more-video-sites-bb-code-media.7608/page-8#post-275009

Especially this:

Jake Bunce said:
Match URLs: #http://soundcloud\.com/(?P<id>[\-a-z0-9_]+/[\-a-z0-9_]+)$#siU
...
And be sure to enable Use 'Match URLs' as PCRE regular expressions under Advanced Options.
And this:

Admin CP -> Home -> Options -> Messages -> Auto-Embed Media Links
 

audiokid

Active member
#18
I have all this the same and this selected here:
Admin CP -> Home -> Options -> Messages -> Auto-Embed Media Links

Auto-embed media, and add a link to the content within this BB code:
 

audiokid

Active member
#20
Edit BB Code Media Site

Does the code need to be an iframe instead?

Code:
<object height="81" width="100%">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2F{$id}&amp;g=bb"></param>
<param name="allowscriptaccess" value="always"></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2F{$id}&amp;g=bb" type="application/x-shockwave-flash" width="100%"></embed>
</object>