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

XF 1.5 vbulletin tags.php to Xenforo redirect

Alfa1

Well-known member
#1
I am currently using @xfrocks tags.php
I have tried various 301 redirection rules that are posted around the forums by @Jake Bunce

However, with all solutions I find that this:
/forum/tags.php?tag=word1+word2

is redirected to:
/tags/word1+word2/

while it should redirect to:
/tags/word1-word2/

Does anyone have an idea to fix this?
 

Mike

XenForo developer
Staff member
#2
You're going to need a script to do this sort of manipulation.

Without doing any testing, if you put this in the tags.php script before it builds the tag URL, this may help:
Code:
$input['tag'] = XenForo_Model::create('XenForo_Model_Tag')->normalizeTag($input['tag']);
$input['tag'] = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($input['tag'])));
$input['tag'] = preg_replace('/[ -]+/', '-', $input['tag']);
 

Mike

XenForo developer
Staff member
#4
With the code I provided, it shouldn't have any spaces left -- the last line replaces them with a "-".

I tested the lines locally and "word1 word2" (which is what your original URL would pass to PHP) turns into "word1-word2".
 

Mike

XenForo developer
Staff member
#6
It should go right before:
Code:
$target = XenForo_Link::buildPublicLink('canonical:tags', $input['tag'], $extraParams);
If you're testing after changes, use different URLs in each test. Browsers cache 301s so you need to avoid that. At least add "&x=1" and so on to the original URL to ensure you're running the most recent code.